Forum Discussion
Difference between rows by grouping with multiple columns
- Anonymous4 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.
Hi Anonymous
when using power bi visuals, aggregation happens automatically. The only thing which is required in your case is to move the year column filter one year back.
Value =
SUM ( TableA[Value] )Value Previous Year =
VAR CurrentYear =
MAX ( TableA[Year] )
RETURN
CALCULATE ( [Value], TableA[Year] = CurrentYear - 1 )Difference =
[Value] - [Value Previous Year]
Hi tamerj1 ,
Thanks for the response.
I tried the solution you proposed but it isn't working with the direct query model.
Function 'CALCULATE' is not allowed as part of calculated column DAX expressions on DirectQuery models.
- tamerj14 years agoCommunity Champion
Hi Anonymous
Please create as new measures not calculated columns.