Forum Discussion
LouiseR
2 years agoRegular Visitor
Add Icons based on Variance from Previous Day
Hello there, I need some help. I am trying to create a matrix (multi-level visual) that has icons (R/A/G) to indicate whether the number went up or down from previous day. My data table looks li...
- 2 years ago
Hi,
Here is how to do this:
Data:Dax:
Test for previous =var _p = MAX('Table (15)'[Date])var _cv = MAX('Table (15)'[Value])var _pv = CALCULATE(MAX('Table (15)'[Value]),ALL('Table (15)'[Date]),'Table (15)'[Date]<_p)RETURNSWITCH(TRUE(),_cv=_pv,0, //same_cv<_pv,1, //up_cv>_pv,2) //down
Add rule:
End result:
If you don't want arrows on the first row change the dax:
Test for previous =var _p = MAX('Table (15)'[Date])var _cv = MAX('Table (15)'[Value])var _pv = CALCULATE(MAX('Table (15)'[Value]),ALL('Table (15)'[Date]),'Table (15)'[Date]<_p)RETURNSWITCH(TRUE(),_cv=_pv,0, //same_cv<_pv,1, //up_pv=BLANK(),BLANK(),_cv>_pv,2) //down
I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!
My LinkedIn: https://www.linkedin.com/in/n%C3%A4ttiahov-00001/
ValtteriN
2 years agoCommunity Champion
Hi,
Here is how to do this:
Data:
Dax:
Test for previous =
var _p = MAX('Table (15)'[Date])
var _cv = MAX('Table (15)'[Value])
var _pv = CALCULATE(MAX('Table (15)'[Value]),ALL('Table (15)'[Date]),'Table (15)'[Date]<_p)
RETURN
SWITCH(TRUE(),
_cv=_pv,0, //same
_cv<_pv,1, //up
_cv>_pv,2) //down
Add rule:
End result:
If you don't want arrows on the first row change the dax:
Test for previous =
var _p = MAX('Table (15)'[Date])
var _cv = MAX('Table (15)'[Value])
var _pv = CALCULATE(MAX('Table (15)'[Value]),ALL('Table (15)'[Date]),'Table (15)'[Date]<_p)
RETURN
SWITCH(TRUE(),
_cv=_pv,0, //same
_cv<_pv,1, //up
_pv=BLANK(),BLANK(),
_cv>_pv,2) //down
I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!
My LinkedIn: https://www.linkedin.com/in/n%C3%A4ttiahov-00001/
- LouiseR2 years agoRegular Visitor
Your solution is great, however in my Matrix visual - it is the sum of the count.
The results look weird and even if the numbers go up or down it doesn't change the icons/results.
Below is the image of the Data table as well.
Appreciate your help on this.