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.
Hi,
I have question about YTD Last year DAX formula. Even though I have read many blogs and topics here in community, I still don't know how to solve this issue.
Suppose I have data like below.
ID | Date | Amount |
1 | 01.01.2016 | 10 |
2 | 02.01.2016 | 15 |
3 | 03.01.2016 | 11 |
4 | 10.01.2016 | 8 |
5 | 20.02.2016 | 7 |
6 | 01.01.2017 | 10 |
7 | 02.01.2017 | 12 |
8 | 03.01.2017 | 9 |
I would like to figure up YTD value of amount for actual data (year 2017) and then YTD value for corresponding period previous year.
For YTD I use formula:
YTD = CALCULATE(SUM(Data[Amount]);DATESYTD(Date[Date]))
For YTD LY I use formula:
YTD LY = CALCULATE([YTD];SAMEPERIODLASTYEAR(Date[Date]))
Then when I use these formulas in PBI, I have got incorrect value for YTD LY. I expect value 36 (dates: 1.1. - 3.1. 2016), but in total I have got 44 (it also calculates Amount 8 in 10.1.2016) - so it gives me period of january 2016, but I want only the corresponding days from 2017.
But YTD LY value in pic below on row for 3.1.2017 is OK.
Does anybody know the solution?
Thanks.
Regards.
Pavel
Solved! Go to Solution.
It should work fine in Power BI.
You didn't have any dates in your Data table beyond 3 Jan 2017 did you?
Here is a sample PBIX file with your data posted above where the measure is working:
I made a small change to the YTD measure so that it is not displayed after the max date in Data table, but the YTD LY measure is the same as I posted.
Have a play with that - there must be some difference in your model if it is not working.
Owen
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 |
---|---|
114 | |
97 | |
85 | |
70 | |
61 |
User | Count |
---|---|
151 | |
121 | |
104 | |
87 | |
67 |