Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Conditionally format matrix cell value based on previous year value

Hi   I've been searching for a solution to my request but can't seem to find one that works unfortunately so reaching out for help!   I have a simple matrix table with categories as row titles an...
  • SolomonovAnton's avatar
    SolomonovAnton
    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 )

  • Anonymous's avatar
    Anonymous
    4 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