Forum Discussion

tasmiaa's avatar
tasmiaa
Advocate I
7 years ago
Solved

How to color a filled map dynamically

I have the following data:   Table with countries, date, and a value Country Value Year USA 3 2016 France 6 2016 Germany 2 2016 USA 1 2017 France 4 2017 Germany 5...
  • tasmiaa's avatar
    7 years ago

    I found the solution:

    1. Keep measure Avg_Val_CurrentYear
    2. Create a new table-
      Table = SUMMARIZE(NATURALINNERJOIN('Table', 'Date'),'Table'[Country],'Date'[Date], "Value", [Avg_Val_CurrentYear] )
    3. Create a measure on the table for previous year
      Avg_Val_PreviousYear = CALCULATE (
      AVERAGE(Value),
      ALLEXCEPT ( 'Table', 'Table'[Country], 'Table'[Date]),
      DateADD('Table'[Date], -1, Year))
    4. Create a calculated column on the table
      Color = If(Value < Avg_Val_PreviousYear, "red", "green")
    5. Create a filled map with the country, value and color