Forum Discussion
Anonymous
1 year agoNot applicable
Getting the previous record values
StoreName FormDate Sum of TotalScore A 09-11-2022 00:00 2 A 05-05-2023 00:00 95 A 16-11-2023 00:00 99 A 23-04-2024 00:00 98 A 19-11-2024 00:00 96 B 02-11-2022 00:00 ...
- Anonymous1 year ago
Hi Anonymous ,
I create a table as you mentioned.
Then I think you can create a new table and here is the DAX code.
NewTable = SUMMARIZE ( 'Table', 'Table'[StoreName], "Latest Score", CALCULATE ( MAX ( 'Table'[Sum of TotalScore] ), 'Table'[FormDate] = MAX ( 'Table'[FormDate] ) ), "Previous Score", CALCULATE ( MAX ( 'Table'[Sum of TotalScore] ), 'Table'[FormDate] = MAXX ( FILTER ( 'Table', 'Table'[StoreName] = EARLIER ( 'Table'[StoreName] ) && 'Table'[FormDate] < MAX ( 'Table'[FormDate] ) ), 'Table'[FormDate] ) ) )Best Regards
Yilong Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
ryedoesbi
1 year agoNew Member
You could use the RANKX function (descending order) where 1 = your latest date and 2 = your next latest date. You could use the TOPN function to retrieve the top two values each category (i.e. latest date and second latest date) and use the MINX function to get the lowest of these two values. You could use the INDEX function to retrieve the 2nd value from your list when ordered by descending date values.
There's lots of options with DAX 🙂