Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

YTD % DAX calculation.

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. 

 

 

  • 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. 

17 Replies

  • 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)
    • Anonymous's avatar
      Anonymous
      Not applicable

      Thank you so much for the quick reply. I did try but only getting 0 values.

       

      • Tutu_in_YYC's avatar
        Tutu_in_YYC
        Super User

        Do you have a year slicer in the report? If yes, can you choose a year?