Forum Discussion
Values Determined by Year and Month Filter Selection
Morning all
Really hope someone can help me please
I have a table with a set of values in.
Year Month Value
2025 April 10
2025 May 20
2025 June 50
2025 July 100
The values each month are cumulative of the previous months. So if you selecting June you'll get 50, if you select July you'll get 100
The problem i have is that if they select the year filter and dont select a month I want it to show the latest figure from the latest month so July . However when I select the year only its summing up all the values and giving me an incorrect figure of 180.
Does anyone know what DAX to do to make sure that depending which filter they choose, either month or year, they get the corret value
Hope this makes sense
Kind regards
Karen
Hi KarenFingerhut ,
Totally makes sense — since your values are cumulative, you don’t want to sum them when only the year is selected. Instead, you want to return the latest value from the selected period.
Here’s a DAX measure that should do the trick:
Latest Cumulative Value = VAR SelectedYear = SELECTEDVALUE('YourTable'[Year]) VAR LatestMonth = CALCULATE( MAX('YourTable'[Month]), 'YourTable'[Year] = SelectedYear ) RETURN CALCULATE( MAX('YourTable'[Value]), 'YourTable'[Year] = SelectedYear, 'YourTable'[Month] = LatestMonth )Replace 'YourTable' with your actual table name, and make sure the Month column is either a proper date or has a sort order (e.g., April = 4, May = 5, etc.).
If your Month column is text (like "April", "May"), you’ll need a separate column that gives it a numeric order so MAX() works correctly.
Here’s a Microsoft doc that might help with time intelligence and filtering:
https://learn.microsoft.com/en-us/power-bi/transform-model/desktop-date-tablesLet me know if you need help adapting this to your model!
If my response resolved your query, kindly mark it as the Accepted Solution to assist others. Additionally, I would be grateful for a 'Kudos' if you found my response helpful.
This response was assisted by AI for translation and formatting purposes.
6 Replies
- burakkaragoz
Super User
Hi KarenFingerhut ,
Totally makes sense — since your values are cumulative, you don’t want to sum them when only the year is selected. Instead, you want to return the latest value from the selected period.
Here’s a DAX measure that should do the trick:
Latest Cumulative Value = VAR SelectedYear = SELECTEDVALUE('YourTable'[Year]) VAR LatestMonth = CALCULATE( MAX('YourTable'[Month]), 'YourTable'[Year] = SelectedYear ) RETURN CALCULATE( MAX('YourTable'[Value]), 'YourTable'[Year] = SelectedYear, 'YourTable'[Month] = LatestMonth )Replace 'YourTable' with your actual table name, and make sure the Month column is either a proper date or has a sort order (e.g., April = 4, May = 5, etc.).
If your Month column is text (like "April", "May"), you’ll need a separate column that gives it a numeric order so MAX() works correctly.
Here’s a Microsoft doc that might help with time intelligence and filtering:
https://learn.microsoft.com/en-us/power-bi/transform-model/desktop-date-tablesLet me know if you need help adapting this to your model!
If my response resolved your query, kindly mark it as the Accepted Solution to assist others. Additionally, I would be grateful for a 'Kudos' if you found my response helpful.
This response was assisted by AI for translation and formatting purposes.- KarenFingerhut
Responsive Resident
HI burakkaragoz
Thanks so much for getting back to me so promptly. I'll give your suggestion a whirl and let you know 😁
Once again thank you
Kind regards
Karen
- KarenFingerhut
Responsive Resident
Hi burakkaragoz This worked a treat, thanks very much. Kind regards Karen
- danextian
Super User
What visual do you want the value to be shown in? And what dimensions would you be adding to that visual?
- KarenFingerhut
Responsive Resident
HI danextian thanks for you reply 🙂 burakkaragoz responded and his explanation worked a treat. Kind regards Karen
- v-karpurapud
Community Support
Hi KarenFingerhut
We are following up regarding your query. Could you please confirm if the issue has been resolved?If so, kindly mark the helpful response and accept it as the solution to assist other community members in resolving similar issues more efficiently. If not, please provide detailed information so we can better assist you.
Thank You.