Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hello community,
I was interested in "how to calculate year-to-date sales more efficient". Until today, I always said something like this:
MaxDate = 29.09.2020
YearStart = 01.01.2020
Calculate(Sum(Sales), Filter( YearStart<=Date <= MaxDate))
But there must be a more elegant way to do this. I tried the DAX-Functions TOTALYTD & a combination of CALCULATE + DATESYTD like this:
TOTALYTD
TOTALYTD( CALCULATE (Sum ( 'SALES'[Amount] ) ),'SALES'[Date] )
RESULT: Sum up whole year (500 instead of 350 till today)
CALCULATE + DATESYTD
CALCULATE( Sum ( 'SALES'[Amount] ), DATESYTD ( 'SALES'[Date] ) )
RESULT: Sum up whole years (3000 instead of 350 till today)
What am I missing? Why is Power BI including all values till year-end and doesn't stop at todays date (29.09.2020)? Thank you in advance!
Solved! Go to Solution.
@Anonymous
To use Time intelligence functions, you need a Date Table as a Dimension table with continuous dates covering the range of dates in your model.
You then use the Dates Table [Date] field in the expressions instead of your Sales [Date]
Proud to be a Super User!
Paul on Linkedin.
@Anonymous
To use Time intelligence functions, you need a Date Table as a Dimension table with continuous dates covering the range of dates in your model.
You then use the Dates Table [Date] field in the expressions instead of your Sales [Date]
Proud to be a Super User!
Paul on Linkedin.
Hi PaulDBrown,
thanks. Now, it calculcates the running total. But still till the end of year and not ytd.
Is a flag or explicit definition of todays date mandatory?
I'd expect that the calculation ends up here...
@Anonymous
Yes, if you want the measure to stop at Today's date you need to specify it (otherwise it will return the values included in the filter context).
One way of doing this is:
today cutoff =
IF(MAX(Date[Date]<= TODAY(), [Sales Ytd TotalYtd])
Proud to be a Super User!
Paul on Linkedin.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
106 | |
93 | |
75 | |
62 | |
50 |
User | Count |
---|---|
146 | |
109 | |
106 | |
88 | |
61 |