Forum Discussion

Burubear's avatar
Burubear
Helper I
6 years ago
Solved

Previous Quarter value

Hi All,   This is a follow-up from my previous thread here https://community.powerbi.com/t5/Power-Query/Calculate-the-previous-date-for-each-item/m-p/1043531   Since I created a new previous qua...
  • mahoneypat's avatar
    mahoneypat
    6 years ago

    This measure should do what you are looking for.  It works on a table like the one you've shown (e.g., where Team, Qtr, and Year are all included in the context of the visual, so the SelectedValue parts work).

     

    Avg Prev Qtr = var prevyear = SELECTEDVALUE(Scores[Previous Qtr Yr])
    var prevqtr = SELECTEDVALUE(Scores[Prev Qtr])
    return CALCULATE(AVERAGE(Scores[Score (1-10)]), all(Scores), VALUES(Scores[Team]), Scores[Year]=prevyear, Scores[Prefix]=prevqtr)
     
    If it works for you, please mark it as the solution.  Kudos are great too.  Please let me know if it doesn't or if any questions.
    Regards,
    Pat