Forum Discussion
Most recent date measure
I am trying to calculate thhe most recent product level by date and user, but i am looking to show this as a chart that counts the number of products IDs by product level. But will need to be by the max date as i only want to look at the latest date below is some sample data i am working with;
IdUsernameProduct IDProduct LevelDate
| 1 | John | 1 | 3 | 06/02/2020 |
| 2 | John | 1 | 1 | 07/02/2020 |
| 3 | John | 2 | 3 | 25/02/2020 |
| 4 | Steve | 3 | 1 | 18/02/2020 |
| 5 | Steve | 3 | 3 | 10/02/2020 |
| 6 | Steve | 4 | 1 | 07/02/2020 |
| 7 | Steve | 4 | 3 | 06/02/2020 |
| 8 | Steve | 4 | 0 | 04/02/2020 |
| 9 | Steve | 5 | 3 | 24/02/2020 |
| 10 | Steve | 6 | 1 | 07/02/2020 |
Hi Anonymous ,
Try this:
Most Recent Date by User = CALCULATE ( MAX ( 'Table'[Date] ), FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Username] = MAX ( 'Table'[Username] ) ) )count = IF ( [Most Recent Date by User] = MAX ( 'Table'[Date] ), COUNTROWS ( FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Username] = MAX ( 'Table'[Username] ) && 'Table'[Product Level] = MAX ( 'Table'[Product Level] ) ) ) )Best regards
Icey
If this post helps, then consider Accepting it as the solution to help other members find it more quickly.
5 Replies
- amitchandak
Super User
Anonymous , can you share expected output in table format.
This can work
lastnonblankvalue(table[LevelDate],max(Table[Product Leve]))
But I think you said this will not solve the purpose on the last reply on last topic
- AnonymousNot applicable
amitchandak No it wont work, i need the table to do a count of product Ids that sit per level. But i only want to look at the max date per product ID
- amitchandak
Super User
Anonymous , try like
countx(filter(summarize(Table,table[user], table[product],table[Product Level],"_1", calculate(lastnonblankvalue(table[LevelDate],max(Table[Product Leve])),allexcept(Table,table[user], table[product]))) ,[_1] =[Product Level]),[product])
- AnonymousNot applicable
amitchandak its still not working i can do it statically by taking the max date then saying if date = max date then take level but i need to be able to do this dynamically to change when a date is filtered
- Icey
Community Support
Hi Anonymous ,
Try this:
Most Recent Date by User = CALCULATE ( MAX ( 'Table'[Date] ), FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Username] = MAX ( 'Table'[Username] ) ) )count = IF ( [Most Recent Date by User] = MAX ( 'Table'[Date] ), COUNTROWS ( FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Username] = MAX ( 'Table'[Username] ) && 'Table'[Product Level] = MAX ( 'Table'[Product Level] ) ) ) )Best regards
Icey
If this post helps, then consider Accepting it as the solution to help other members find it more quickly.