Forum Discussion

BassG's avatar
BassG
Icon for Helper I rankHelper I
2 years ago
Solved

Compare with previous year

Sorry for posting 2 questions in 1 day. I'm looking to create something that looks like this... Setting Selected year attendance % Previous Year's quarter attendance % Difference % P...
  • amitchandak's avatar
    2 years ago

    BassG , Try following measure

    % Attend = DIVIDE(SUM(Data[Actual Attendance]), sum(Data[Possible Attendance]))
    Last Year = CALCULATE([% Attend], OFFSET(-4, all(Data[Year], Data[Quarter],Data[Setting]), ORDERBY(Data[Year],asc, Data[Quarter],asc)))

     

    file is attached

  • MFelix's avatar
    2 years ago

    Hi BassG ,

     

    Add a custom column with the Quarter end date then just use that column to make the calculations you need.

     

    Code for the column is the following

    Date.EndOfQuarter (#date([Year],Number.FromText (Text.End([Quarter],1)) - 1 * 3 + 3,1))

     

     

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi BassG ,

    You can add two tables to create slicers:

    And there is no relationship between tables:

    Use these DAXs to create measures:

    Selected year attendance % = 
    VAR Y = SELECTEDVALUE(Slicer[Year])
    VAR Q = SELECTEDVALUE(Slicer2[Quarter])
    VAR ACTUAL = SUMX(FILTER('Table', 'Table'[Year] = Y && 'Table'[Quarter] = Q), 'Table'[Actual Attendance])
    VAR POSSIBLE = SUMX(FILTER('Table', 'Table'[Year] = Y && 'Table'[Quarter] = Q), 'Table'[Possible Attendance])
    RETURN
    DIVIDE(ACTUAL, POSSIBLE)
    Previous Year's quarter attendance % = 
    VAR Y = SELECTEDVALUE(Slicer[Year])
    VAR Q = SELECTEDVALUE(Slicer2[Quarter])
    VAR ACTUAL = SUMX(FILTER('Table', 'Table'[Year] = Y - 1 && 'Table'[Quarter] = Q), 'Table'[Actual Attendance])
    VAR POSSIBLE = SUMX(FILTER('Table', 'Table'[Year] = Y - 1 && 'Table'[Quarter] = Q), 'Table'[Possible Attendance])
    RETURN
    DIVIDE(ACTUAL, POSSIBLE)
    Difference % = [Selected year attendance %] - [Previous Year's quarter attendance %]

    The final output is as below:


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