The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Hi - I hope someone can help me. I am lookign to calculate YTD%, (which is basically supposed to be -- (CurrentQ - prior 12/31) / prior 12/31) ).
I have used quick measure to calculate QoQ %, which give me the result I want but when I tried using same format to calculate YTD % i was getting an error.
Solved! Go to Solution.
My mistake, previous calculations will not work in your model.
try this:
YoY% for YTD =
IF(
ISFILTERED('Data2'[Date]),
ERROR("Time intelligence quick measures can only be grouped or filtered by the Power BI-provided date hierarchy or primary date column."),
VAR __PREV_YEAR = CALCULATE(TOTALYTD(SUM('Data2'[$]), 'Data2'[Date].[Date]), DATEADD('Data2'[Date].[Date], -1, YEAR))
RETURN
DIVIDE(TOTALYTD(SUM('Data2'[$]), 'Data2'[Date].[Date]) - __PREV_YEAR, __PREV_YEAR)
)
This will compare the current YTD accumulation to previous year YTD and calculate the YOY growth.
Hi Rilwan,
try this:
YTD% =
VAR _Current = TOTALYTD(SUM(Data2[$]), Data2[Date])
VAR _Previous = CALCULATE( TOTALYTD(SUM(Data2[$]), Data2[Date]), SAMEPERIODLASTYEAR(Data2[Date]))
RETURN
DIVIDE( _Current - _Previous, _Previous, 0)
Thank you so much for the quick reply. I did try but only getting 0 values.
Do you have a year slicer in the report? If yes, can you choose a year?
Yes, i did choose a year and still getting 0 values.
Can you create this for validation, and put it in the matrix? Upload a snapshot.
Validation =
VAR _Current = TOTALYTD(SUM(Data2[$]), Data2[Date])
VAR _Previous = CALCULATE( TOTALYTD(SUM(Data2[$]), Data2[Date]), SAMEPERIODLASTYEAR(Data2[Date]))
RETURN
_Current & "---" & _Previous
That tells me that you do not have data for previous year. Is that the case?
What year are you looking at in the below snapshot?
I do have data for previous year. Also, understand these are quarterly data. Let me get you a screen shot.
My mistake, previous calculations will not work in your model.
try this:
YoY% for YTD =
IF(
ISFILTERED('Data2'[Date]),
ERROR("Time intelligence quick measures can only be grouped or filtered by the Power BI-provided date hierarchy or primary date column."),
VAR __PREV_YEAR = CALCULATE(TOTALYTD(SUM('Data2'[$]), 'Data2'[Date].[Date]), DATEADD('Data2'[Date].[Date], -1, YEAR))
RETURN
DIVIDE(TOTALYTD(SUM('Data2'[$]), 'Data2'[Date].[Date]) - __PREV_YEAR, __PREV_YEAR)
)
This will compare the current YTD accumulation to previous year YTD and calculate the YOY growth.
Thank you so much. I apprciate you. That worked right.
glad to hear!
Hi - What about in the case of wanting to calculate,
example
YTD = Q4 2021 - Q4 2020
QTD = Q4 - Q3
YTD = Q4 2021 - Q4 2020 : As in the difference of the amount beween current year and previous year?
QTD = Q4 - Q3 : Difference from current Quarter to the previous Quarter ( i.e Qn - Qn-1)?
Got this sorted. Thank you
But i have another question on how to write this R code in Dax.
Filter(!is.na(SentMonth), Surveytaken==2)
Ooh not proficient in R.
But try this
EOC_Sent = CALCULATE(countrows('Sheet1'), 'Sheet1'[SurveyTaken]=2)
If it doesnt work, it means your table structure may not be correct.