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, beginner question here but here goes!
I am trying to use the time-intelligence functions in order to avoid hard-coding fixed dates into my formulas.
Context:
YTD Revenue = TOTALYTD(SUM(FactFinancialsGP[Revenue]), DimDateAccrued[DateKey Accrued])
Revenue PYTD = CALCULATE([YTD Revenue], SAMEPERIODLASTYEAR(DimDateAccrued[DateKey Accrued]))
2015 Revenue = CALCULATE(SUM(FactFinancialsGP[Revenue]), DimDateAccrued[Year Accrued] = 2015)
However, Revenue PYTD behaves wrong. It is cummalitively summing the revenue month-over-month, instead of plotting the revenue for each month respectively.
2015 Revenue measure plots it correctly, as seen in the photo.
Question: Why does SamePeriodLastYear behave this way versus the hard-coded measure?
@greggyb perhaps you could enlighten me 🙂
Thank you everyone in advance
Solved! Go to Solution.
You're getting a YTD total with SAMEPERIODLASTYEAR() because the expression that you are evaluating is a YTD measure. Use the DAX below to have a measure that will automatically mirror the current context, just shifted one year back.
=CALCULATE( SUM( FactFinancialsGP[Revenue] ) ,SAMEPERIODLASTYEAR( DimDateAccrued[DateKey Accrued] ) )
your Revenue PYTD measure works as expected. You only have data for one month in the current year, therefore your YTD for current year is parallel to X, however, you probably have data for every month of the prior yer, therefore, your YTD for Prior year sums all prior periods for each period, which is how the YTD calc is supposed to work. If you only want to show what the revenue was in that period, don't user TOTALYTD function, just use the Sum().
try to set your relationship to the Date table from Both to Single
I can reproduce. You've got bidirectional relationships in the chain from DimFinancialsGMMS to DimDateAccrued.
I'm assuming [Client] exists in DimFinancialsGMMS. When you click on a client in the chart, that filter flows all the way through to DimDateAccrued. If you select a client that does not have rows in FactMoves for every single date in the two years we're considering, then DimDateAccrued is filtered down to a less than contiguous range of dates.
Change your relationship between DimDateAccrued and FactMoves into a one-way relationship.
your Revenue PYTD measure works as expected. You only have data for one month in the current year, therefore your YTD for current year is parallel to X, however, you probably have data for every month of the prior yer, therefore, your YTD for Prior year sums all prior periods for each period, which is how the YTD calc is supposed to work. If you only want to show what the revenue was in that period, don't user TOTALYTD function, just use the Sum().
You're getting a YTD total with SAMEPERIODLASTYEAR() because the expression that you are evaluating is a YTD measure. Use the DAX below to have a measure that will automatically mirror the current context, just shifted one year back.
=CALCULATE( SUM( FactFinancialsGP[Revenue] ) ,SAMEPERIODLASTYEAR( DimDateAccrued[DateKey Accrued] ) )
Perfect! Very clear explanation. Thank you sir
Hello,
So I have another question about the contiguous date requirements of SamePeriodLastYear function.
Let me describe my setup to help illustrate what I am trying to do.
Setup:
Move Count PYTD = CALCULATE(COUNTA(DimFinancialsGMMS[Moves ]), SAMEPERIODLASTYEAR(DimDateAccrued[DateKey Accrued]))
Problem:
Is there any way you can share a sample .pbix file that reproduces the issue?
Unfortunately I cannot share this particular .pbix file.
Here are some photos (Ignore Growth column):
I can reproduce. You've got bidirectional relationships in the chain from DimFinancialsGMMS to DimDateAccrued.
I'm assuming [Client] exists in DimFinancialsGMMS. When you click on a client in the chart, that filter flows all the way through to DimDateAccrued. If you select a client that does not have rows in FactMoves for every single date in the two years we're considering, then DimDateAccrued is filtered down to a less than contiguous range of dates.
Change your relationship between DimDateAccrued and FactMoves into a one-way relationship.
try to set your relationship to the Date table from Both to Single
dude...YES!!! Thanks a million.
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 |