Forum Discussion
Get Latest comment for a group
Hello All,
I have a requirement where i need to get the latest comment for a department and ID. So if ID '1' and Department 'X' is slected in the filters, I should get the latest comment that was added for that department and ID. I have tried addding a calculated column as .. and then getting the comment corresponding to that date but this does not work
Please see below the sample dataset, Can you please help me achieve this.
| Department | ID | Modified Date | Comments |
| X | 1 | 01-01-2024 | |
| X | 1 | 10-01-2024 | abcdef |
| X | 1 | 11-02-2024 | qwert |
| Y | 1 | 05-01-2024 | |
| Y | 1 | 12-01-2024 | XCV |
| X | 2 | 02-01-2024 | SDF |
| X | 2 | 11-01-2024 | CVB |
| Expected Result when Month "January" and ID "1" is selected | |||
| Department | ID | Comments | |
| X | 1 | abcdef | |
| Y | 1 | XCV |
Kish1999 Use ALLSELECTED instead of ALL.
Measure = VAR __Dept = MAX('QPlans Historical'[Department]) VAR __ID = MAX('QPlans Historical'[ID]) VAR __Date = MAX('QPlans Historical'[Modified Date]) VAR __MaxDate = MAXX(FILTER(ALLSELECTED('QPlans Historical'), [Department] = __Dept && [ID] = __ID), [Modified Date]) VAR __Result = IF( __Date = __MaxDate, 1, 0) RETURN __Result
3 Replies
- Greg_Deckler
Community Champion
Kish1999 This would be a Complex Selector like so:
The Complex Selector - Microsoft Fabric Community
Measure = VAR __Dept = MAX('QPlas Historical'[Department]) VAR __ID = MAX('QPlans Historical'[ID]) VAR __Date = MAX('QPlans Historical'[Modified Date]) VAR __MaxDate = MAXX(FILTER(ALL('QPlans Historical'), [Department] = __Dept && [ID] = __ID), [Modified Date]) VAR __Result = IF( __Date = __MaxDate, 1, 0) RETURN __Result- Kish1999
Helper II
Hello Greg_Deckler , Thank You for the solution. This measure does not give me the Max date for each of the slected month in the slicer. It returns the overall MaxDate for the Department and ID, not based on the month slected in the slicer.
- Greg_Deckler
Community Champion
Kish1999 Use ALLSELECTED instead of ALL.
Measure = VAR __Dept = MAX('QPlans Historical'[Department]) VAR __ID = MAX('QPlans Historical'[ID]) VAR __Date = MAX('QPlans Historical'[Modified Date]) VAR __MaxDate = MAXX(FILTER(ALLSELECTED('QPlans Historical'), [Department] = __Dept && [ID] = __ID), [Modified Date]) VAR __Result = IF( __Date = __MaxDate, 1, 0) RETURN __Result