Forum Discussion
Getting the Previous Value in a Matrix with 7 rows
I have a Matrix which looks like this
I have 7 Columns in ROWS
"EndOfSnapShotWeek" in the COLUMNS
and "Rev1" and "Rev2" in the VALUES
I want to create two measures that will calculate whether the "Rev1" or "Rev2" VALUES has gone up/down compared to the previous week (EndOfSnapShotWeek column.).
Then I can use that in conditional formatting.
I can handle the conditional formatting I just need help with the DAX.
Sample PBIX file is attached here
Sample PBIX
You have interesting data including negative numbers. Calculating a WoW with a mix of positive and negative numbers is extremely subjective. Make sure you agree with the formula.
Here's my (subjective) version:
Rev1 change = var pr1 = CALCULATE(sum(test[Rev1]),DATEADD('Calendar'[Date],-7,DAY)) return divide(sum(test[Rev1])-pr1,abs(pr1),1)However your x axis is driven by a fact date (end of snapshot week) and not by the dimension date as it should be . You will want to correct that too ( or modify the above formula)
10 Replies
- lbendlin
Super User
use Visual Calculations - particularly PREVIOUS.
- MrHajiCoolBreezFrequent Visitor
This works to calculate the differences but I can't use those Visual Calculations Measures in the Conditional Formatting.
They don't appear in the "which field should we base these on" drop down- lbendlin
Super User
correct, that is a know current limitation
Using visual calculations in Power BI Desktop - Power BI | Microsoft Learn
- MrHajiCoolBreezFrequent Visitor
Do you have a workaround or an alternative approach to solve my initial problem?