Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
Hello, I am using a measure which calculates YTD for previos year but the issue is the measure is working fine but the YTD for last year is in 2023
as you can see in the above screenshot the YTD for 2023 is 8705 if we calculate YTD for 2022 it is 8000 but the values are showing vice-versa can anyone help me what is the problem in DAX
this is the dax I used
Solved! Go to Solution.
Hi @Srinivas3350 ,
According to your description, it seems that you’re trying to calculate the Year-to-Date (YTD) sales for the previous years. And it seems that the returned result is not correct base on current DAX formula. Please update the formula of measure [YTD with Previous Years Sales] as below and check if it can return the correct result...
YTD with Previous Years Sales =
VAR _Last =
CALCULATE (
LASTNONBLANK ( 'Date Table'[Date], [YTD] ),
ALL ( 'Date Table'[Date] )
)
RETURN
IF (
SELECTEDVALUE ( 'Date Table'[Date] ) <= _Last,
CALCULATE ( [YTD], SAMEPERIODLASTYEAR ( 'Date Table'[Date] ) )
)
If the above one can't help you get the expected result, please provide some raw data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It would be helpful to find out the solution. You can refer the following link to share the required info:
How to provide sample data in the Power BI Forum
And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.
How to upload PBI in Community
Best Regards
Hi @Srinivas3350 ,
According to your description, it seems that you’re trying to calculate the Year-to-Date (YTD) sales for the previous years. And it seems that the returned result is not correct base on current DAX formula. Please update the formula of measure [YTD with Previous Years Sales] as below and check if it can return the correct result...
YTD with Previous Years Sales =
VAR _Last =
CALCULATE (
LASTNONBLANK ( 'Date Table'[Date], [YTD] ),
ALL ( 'Date Table'[Date] )
)
RETURN
IF (
SELECTEDVALUE ( 'Date Table'[Date] ) <= _Last,
CALCULATE ( [YTD], SAMEPERIODLASTYEAR ( 'Date Table'[Date] ) )
)
If the above one can't help you get the expected result, please provide some raw data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It would be helpful to find out the solution. You can refer the following link to share the required info:
How to provide sample data in the Power BI Forum
And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.
How to upload PBI in Community
Best Regards
Sorry 2021 value is 8705
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
21 | |
15 | |
14 | |
11 | |
7 |
User | Count |
---|---|
25 | |
24 | |
12 | |
12 | |
11 |