Forum Discussion
Filtering table for rows showing the max date per group
- 3 years ago
Ok, you should create a new table (in my case Sheet1_filtered) with a column named consumerID (same name as your current table). You can get the distinct ids via:
Sheet1_filtered = DISTINCT(Sheet1[ConsumerID])You can than calculate the most recent VisitDate for each ConsumerID in a new column.
MostRecentVisitDate = CALCULATE ( MAX (Sheet1[VisitDate]), FILTER ( Sheet1, Sheet1[ConsumerID] = EARLIER ( Sheet1_filtered[ConsumerID] ) ) )Make sure there is a relationship between the two consumerID in both tables (use the model view).
Sheet1 is your current table. Sheet1_filtered will the table that you should create.
Let me know if this works.
Best,
Milan
- 3 years ago
Cool cool, try in the filtered table:
RelatedRowID = VAR ConsumerID = Sheet1_filtered[ConsumerID] VAR MostRecentVisitDate = Sheet1_filtered[MostRecentVisitDate] RETURN CALCULATE ( MAX( Sheet1[RowID]), Sheet1[ConsumerID] == ConsumerID && Sheet1[VisitDate] == MostRecentVisitDate )Best,
Milan
PS. Make sure to thumbs up and mark as solution if it fits your needs.
Hey, just to be sure... Do you want this as a measure or do you want a new table with the filtered data? Best, Milan
Hi there,
Ideally, I'm looking for a filtered table that retains all the columns. Thank you for taking a look at this!