Forum Discussion
YTD value (not cumulative)
Hello,
I would like to ask for your help. I would like to get the YTD value of consumer count. But the thing, it SHOULD NOT be cummulative. I just want to get the max value of the date available. I do have a calendar date linked to the sales table.
Example:
In this table, the YTD value of the consumer count is 380. Since it is the latest data.
Year (from Date dimension) | Month (from Date dimension) | Consumer Count (from fact table) |
| 2023 | Jan | 331 |
| 2023 | Feb | 332 |
| 2023 | Mar | 333 |
| 2023 | Apr | 336 |
| 2023 | May | 338 |
| 2023 | Jun | 339 |
| 2023 | Jul | 340 |
| 2023 | Aug | 345 |
| 2023 | Sep | 356 |
| 2023 | Oct | 360 |
| 2023 | Nov | 369 |
| 2023 | Dec | 380 |
Could somebody help me.
Thannks!
- Anonymous2 years ago
Hi icdns ,
According to your description, here are my steps you can follow as a solution.
(1) This is my test data.
FactTable:
DateTable = ADDCOLUMNS(CALENDAR(DATE(2023,1,1),DATE(2023,12,31)),"year",YEAR([Date]),"monthno",MONTH([Date]),"month",FORMAT([Date],"mmm"))(2) We can create a measure.
Measure = VAR _maxdate = CALCULATE ( MAX ( 'FactTable'[Date] ), ALLSELECTED ( 'FactTable' ) ) RETURN CALCULATE ( SUM ( 'FactTable'[YTD] ), FILTER ( ALL ( 'DateTable' ), 'DateTable'[year] = YEAR ( _maxdate ) && 'DateTable'[monthno] = MONTH ( _maxdate ) ) )(3) Then the result is as follows.
If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.
Best Regards,
Neeko Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
2 Replies
- Daniel29195
Community Champion
Hello icdns
Measure = var datasource = addcolumns( allselected(Data[Date]), "@x" , calculate( SUM(Data[Sales])) ) var max_data = MAXX( datasource, [@x] ) return max_dataedit the above vode according to your tablenames and colum names.
If my answer helped sort things out for you, i would appreciate a thumbs up 👍 and mark it as the solution !✅
It makes a difference and might help someone else too. Thanks for spreading the good vibes! 🤠 - AnonymousNot applicable
Hi icdns ,
According to your description, here are my steps you can follow as a solution.
(1) This is my test data.
FactTable:
DateTable = ADDCOLUMNS(CALENDAR(DATE(2023,1,1),DATE(2023,12,31)),"year",YEAR([Date]),"monthno",MONTH([Date]),"month",FORMAT([Date],"mmm"))(2) We can create a measure.
Measure = VAR _maxdate = CALCULATE ( MAX ( 'FactTable'[Date] ), ALLSELECTED ( 'FactTable' ) ) RETURN CALCULATE ( SUM ( 'FactTable'[YTD] ), FILTER ( ALL ( 'DateTable' ), 'DateTable'[year] = YEAR ( _maxdate ) && 'DateTable'[monthno] = MONTH ( _maxdate ) ) )(3) Then the result is as follows.
If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.
Best Regards,
Neeko Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.