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

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.

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

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.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.