Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Difference between rows by grouping with multiple columns

Hi All, I am quite new to Power BI. I have a table where I have to calculate the difference between previous yr and current yr value by grouping data by different attributes.  Year Univ Schoo...
  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi Anonymous 

    First , you need create a measure to return the previous value .

     

    PreviousValue = CALCULATE(SELECTEDVALUE('Table'[Value]),FILTER(ALLEXCEPT('Table','Table'[Univ],'Table'[School]),'Table'[Year]=SELECTEDVALUE('Table'[Year])-1))

     

    Then create a measure to count the diff between previous year and current year .

     

    Diff = IF([PreviousValue] <> BLANK(),SELECTEDVALUE('Table'[Value])-[PreviousValue],BLANK())

     

    Finally, put these two measures in your table visual , you will get a result like below .

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