Search code examples
powerbipowerbi-desktoppowerbi-custom-visuals

Power BI Filled Map Conditional Coloring


I want to color countries based on minimum and maximum values in Power BI filled maps. I created a Summary measure that shows sum of cost in tool tip and Color measure for conditional formatting. In this case, it looks like the map is not considering any condition in the switch statement and returns the color mentioned first. Anyone know how to solve this?

[Summary Measure](https://i.sstatic.net/bV5vt.png)

Color Measure Filled Map


Solution

  • You need to use ALL(table) to get the whole table and break-away from the row context. Try...

    Color = 
      var maxAll = CALCULATE(MAX('Test Table[Summary]'), ALL('Test Summary'))
      var minAll = CALCULATE(Min('Test Table[Summary]'), ALL('Test Summary'))
      var current = MAX('Test Table[Summary]')
    
      return SWITCH(TRUE(),
        current = maxAll, "Red",
        current = minAll, "Green"
      )