Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

Need help with YTD calculation in DAX

Dilpreeth_0-1611062053081.png

 

Hello All,

 

I am trying to create a YTD measure which will sum the values under column plan_decimal. The values are repeating due to 2 unique accounts for each month and that column needs to be retained resulting in duplication of plan_decimal. 

Can someone help me with the DAX which can give the YTD sum based on this field and Date field.

 

This is what i tried but it adds up the value twice

TOTALYTD(SUM(Data[Plan_decimal]),Data[Date])
 
Expected result when date slicer is selected for:
 
March : 12.75
June :  12.75 + 12.75 (Mar)
Sep : 12.75 + 12.75 (Jun) + 12.75 (Mar)
 
 

 

2 ACCEPTED SOLUTIONS
v-stephen-msft
Community Support
Community Support

Hi @Anonymous ,

 

The measure is

 

ytd = TOTALYTD(SUM(Sheet1[Plan_decimal]),Sheet1[Date])

 

Add a Account slicer to to distinguish A from B.

Screenshot 2021-01-22 152814.png

 

Or you can put your measure and Account column together in a table.

Screenshot 2021-01-22 153229.png

 

Another way is to determine whether Account is A or B in the measure.

 

ytd1 = TOTALYTD(CALCULATE(SUM(Sheet1[Plan_decimal]),FILTER('Sheet1',[Account]="A")),Sheet1[Date])

 

Screenshot 2021-01-22 153657.png

 

You can check more details from here.

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

v-stephen-msft
Community Support
Community Support

Hi @Anonymous ,


Sorry to disturb you...


But did I answer your question ? Please mark my reply as solution. Thank you very much.

 

Best Regards,
Stephen Tao

View solution in original post

8 REPLIES 8
v-stephen-msft
Community Support
Community Support

Hi @Anonymous ,


Sorry to disturb you...


But did I answer your question ? Please mark my reply as solution. Thank you very much.

 

Best Regards,
Stephen Tao

Anonymous
Not applicable

Thanks a lot...sorry for the delay

v-stephen-msft
Community Support
Community Support

Hi @Anonymous ,

 

The measure is

 

ytd = TOTALYTD(SUM(Sheet1[Plan_decimal]),Sheet1[Date])

 

Add a Account slicer to to distinguish A from B.

Screenshot 2021-01-22 152814.png

 

Or you can put your measure and Account column together in a table.

Screenshot 2021-01-22 153229.png

 

Another way is to determine whether Account is A or B in the measure.

 

ytd1 = TOTALYTD(CALCULATE(SUM(Sheet1[Plan_decimal]),FILTER('Sheet1',[Account]="A")),Sheet1[Date])

 

Screenshot 2021-01-22 153657.png

 

You can check more details from here.

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@Anonymous , Always use date table for that

TOTALYTD(SUM(Data[Plan_decimal]),'DAte'[Date])

refer my video why Time intelligence can fail - https://www.youtube.com/watch?v=OBf0rjpp5Hw

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.

 

Power BI — Year on Year with or Without Time Intelligence
https://medium.com/@amitchandak.1978/power-bi-ytd-questions-time-intelligence-1-5-e3174b39f38a
https://www.youtube.com/watch?v=km41KfM_0uA

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here
Anonymous
Not applicable

@amitchandak : Thanks for your reply. I had tried this but the issue is that the value is getting added twice since there are two rows correpoding to each month.

@Anonymous , Try this inplace of sum(Table[Plan_decimal])

 

sumx(values(Date[Date]), calculate(Max(Table[Plan_decimal])))

 

Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here
Anonymous
Not applicable

Anonymous
Not applicable

@amitchandak I am trying to upload the pbix file but can't attach it here

 

Dilpreeth_0-1611065325201.png

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.