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
campelliann
Post Patron
Post Patron

Cannot understand DatesYTD behavior with/without hierarchies

Hi people,


So I have to calculate the accumulated revenue for 2021 and I have a bar chart with the months at the x axis.

I am using Calculate( sum (Table[revenue]), DatesYTD(Calendar[YearMonth].[Date])

 

I am using a Date hierarchy at the month level. I dont understand why it makes a different using .[Date] or not at the end of DatesYTD. With, I get the desired result an accumulated revenue, If I dont use .Date it only gives me the revenue for the particular month (no cumulative) which does not make sense to me, because the "Table" with revenues has always the first day of the month(.Date returns the full calendar)


Thanks

Thanks

1 ACCEPTED SOLUTION

Hi and many thanks for your help. I have already solved this without the YTD. Still I just used the .date because without it would give me each month revenue (not the cumulative). Although I do not understand why...

View solution in original post

3 REPLIES 3
v-xiaotang
Community Support
Community Support

Hi @campelliann 

Thanks for reaching out to us.

Please try this measure

accumulateTotal = CALCULATE(SUM('Table'[revenue]),ALL('Table'),DATESYTD('Calendar'[YearMonth]))

vxiaotang_4-1635318471311.png

-

usually, we don't need to use .[Date] in dax, it only work in date hierarchy row context.

Kindly refer to https://docs.microsoft.com/en-us/power-bi/transform-model/desktop-auto-date-time

 

I also create a sample for your reference, 

test1 = Calculate(SUM('Table'[revenue]), DatesYTD('Table'[Date]))
test2 = Calculate(SUM('Table'[revenue]), DatesYTD('Table'[Date].[Date]))
1, when you don't use date hierarchy, the first measure test1 works ok,
vxiaotang_0-1635317771847.png
2, when you use date hierarchy, the second measure test2 works ok,
vxiaotang_1-1635317866391.png
 
 

Best Regards,

Community Support Team _Tang

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

AlexisOlson
Super User
Super User

I recommend never using the .[Date] suffix (or other similar ones) at all. They tend to cause confusion.

 

I would write it like this:

CALCULATE ( SUM ( Table[revenue] ), DATESYTD ( Calendar[Date] ) )

 

Hi and many thanks for your help. I have already solved this without the YTD. Still I just used the .date because without it would give me each month revenue (not the cumulative). Although I do not understand why...

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.