Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Conditional format a cqard based on a measure

Hi,

I have created a simple visual using cards and measures to give the screenshot below. The section above the line uses measures that are affected by slicers, the section below the line is the same measures but unaffected by slicers.

I want to apply conditional formatting based on the top section being higher or lower in value to the bottom.

As an example, on the right hand side, 611.49 is a higher number than 391.92 so I want the text to turn green, equally I would want it red if it was less.

The numbers in the bottom section are not constants and will change as data is updated.

Is this formatting possible when I'm effectively comparing two outputs from the same measure?

thanks,

Ed

 

 

  • Anonymous's avatar
    Anonymous
    5 years ago

    Hi Anonymous ,

     

    I think you will need to create two separate measures. One of the measure is affected by the slicer, the other is not.

    Then create the third measure to compare these two slicers and use the third slicer as the rule of conditional formatting.

    Please see the example below.

    Measure1 = CALCULATE(AVERAGE('Table'[value]),ALL('Table'))
    
    Measure2 = CALCULATE(AVERAGE('Table'[value]),FILTER(ALL('Table'),'Table'[month]=SELECTEDVALUE('Table'[month])))
    
    Measure3 = IF([Measure1]>[Measure2],1,0)

     

    Best Regards,

    Jay

3 Replies

  • Hi Anonymous ,

     

    You need to create a second measure that compares the values with and without filters.

     

    Assuming that you have a simple measure of a sum what you can do is to create the following measure:

     

     

    Measure = SUM(Table[Column])
    
    
    Comparision Measure = [Measure] - CALCULATE([Measure], ALL(Table))

     

     

    Now you can use the second measure to make the condittional formatting. Be aware that I don't have any information about your model so this measure is not optimized the use of the Table in the ALL syntax is not advised.

     

    But overall setting should be similar to the one above.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

     

    I think you will need to create two separate measures. One of the measure is affected by the slicer, the other is not.

    Then create the third measure to compare these two slicers and use the third slicer as the rule of conditional formatting.

    Please see the example below.

    Measure1 = CALCULATE(AVERAGE('Table'[value]),ALL('Table'))
    
    Measure2 = CALCULATE(AVERAGE('Table'[value]),FILTER(ALL('Table'),'Table'[month]=SELECTEDVALUE('Table'[month])))
    
    Measure3 = IF([Measure1]>[Measure2],1,0)

     

    Best Regards,

    Jay

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thanks Jay, this should work perfectly.