Forum Discussion
Conditionally format matrix cell value based on previous year value
- 4 years ago
error was in the end of script
color =
var _PrevYear =CALCULATE([measure],SAMEPERIODLASTYEAR('Calendar '[Date]))
var _result =SWHITCH (TRUE(),
[measure]>_PrevYear,"green",
[measure]=_PrevYear,"yellow",
"red")if you problem is resiolved please mark topic as resolved )
and click cudoes fror me )
- Anonymous4 years ago
It wasn't actually the " that was causing the problem. The syntax needed to use 'return' instead of another variable.
color =
var _PrevYear =CALCULATE([measure],SAMEPERIODLASTYEAR('Calendar '[Date]))
Return
SWITCH (TRUE(),
[measure]>_PrevYear,"green",
[measure]=_PrevYear,"yellow",
"red")Many thanks for your help as everything is now working as i'd hoped
hello
you should create date table
Calendar = CARENDARAUTO()
after it link the Calendar table with the FAct table you should create measure
color =
var _PrevYear =CALCULATE([measure],SAMEPERIODLASTYEAR('Calendar '[Date]))
var _result =SWHITCH (TRUE(),
[measure]>_PrevYear,"green",
[measure]=_PrevYear,"yellow",
"red)
there [measure] - it is the measure which calculated percent for each year
cafer it create conditonal formating based on the [color] measure
see manual about conditional formating
if you problem is resiolved please mark topic as resolved )
and click cudoes fror me )
- Anonymous4 years agoNot applicable
Many thanks for the reply
But there appears to be a slight problem with the measure. It's giving me a snytax error to do with ')' but i can't see where the issue would be as everything appears to be closed off correctly
- SolomonovAnton4 years agoSuper User
error was in the end of script
color =
var _PrevYear =CALCULATE([measure],SAMEPERIODLASTYEAR('Calendar '[Date]))
var _result =SWHITCH (TRUE(),
[measure]>_PrevYear,"green",
[measure]=_PrevYear,"yellow",
"red")if you problem is resiolved please mark topic as resolved )
and click cudoes fror me )
- Anonymous4 years agoNot applicable
It wasn't actually the " that was causing the problem. The syntax needed to use 'return' instead of another variable.
color =
var _PrevYear =CALCULATE([measure],SAMEPERIODLASTYEAR('Calendar '[Date]))
Return
SWITCH (TRUE(),
[measure]>_PrevYear,"green",
[measure]=_PrevYear,"yellow",
"red")Many thanks for your help as everything is now working as i'd hoped