Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Dynamic YoY percentage %

Hello all,   I've searched mulitple posts on this forum to try to solve this problem and I have had no luck so far.   I want to be able to calculate a percentage change of different fiscal years ...
  • ahadkarimi's avatar
    ahadkarimi
    2 years ago

    Hey Anonymous, make the following changes for the 2nd year:

    RiderSelected2ndYear = 
    VAR SelectedYearNumber = VALUE(RIGHT(SELECTEDVALUE('xFY Calender'[FY]), 2))
    VAR PreviousYearNumber = SelectedYearNumber - 1
    VAR PreviousFY = "FY" & FORMAT(PreviousYearNumber, "00")
    RETURN
    CALCULATE(
        [TotalRiders],
        FILTER(
            ALL('xFY Calender'[FY]),
            'xFY Calender'[FY] = PreviousFY
        )
    )

     

    if you would like to display a dash (-) instead of 'Blank' in the card, use the code below:

    YoY % = 
    IF(
        ISBLANK([RiderSelectedYear]) || ISBLANK([RiderSelected2ndYear]),
        "-",
        DIVIDE([RiderSelectedYear], [RiderSelected2ndYear], 0)
    )

    Please let me know what happend and if there are any issues.