powerbiiconsconditional-formatting

Power BI - Unable to add icons to my table visual


I have a table visual containing the individual quatation entries made by each broker.

Firstly, I wanted it to display the data from the same period of the previous year based on the selection made in my date slicers. For that, I created a measure that calculates the amount of estimated premium using SAMEPERIODLASTYEAR and added it to my table visual, as per below:

GWP Estimado - Ano Anterior = 
    CALCULATE(
        SUM(bi_prospect_analysis_kpw[estimated_premium]),
        SAMEPERIODLASTYEAR('Calendário'[Date])
    )

This worked perfectly. The problem is, I also created a calculated column named "Risk Classification" that classifies each quotation entry as a small, medium or large risk based on specified ranges of estimated premiums that vary for each of our products. When trying to use this column to add icons to my estimated premium column in my table visual, the icons won't show up:

Risk Classification = 
    SWITCH(
        TRUE(),
        // Equipamentos //
        bi_prospect_analysis_kpw[product] = "Equipamentos" && bi_prospect_analysis_kpw[estimated_premium] = 0, "NA",
        bi_prospect_analysis_kpw[product] = "Equipamentos" && bi_prospect_analysis_kpw[estimated_premium] > 0 && bi_prospect_analysis_kpw[estimated_premium] < 50, "P",
        bi_prospect_analysis_kpw[product] = "Equipamentos" && bi_prospect_analysis_kpw[estimated_premium] > 50 && bi_prospect_analysis_kpw[estimated_premium] < 500, "M",
        bi_prospect_analysis_kpw[product] = "Equipamentos" && bi_prospect_analysis_kpw[estimated_premium] > 500, "G",
        // Empresarial //
        bi_prospect_analysis_kpw[product] = "Empresarial" && bi_prospect_analysis_kpw[estimated_premium] = 0, "NA",
        bi_prospect_analysis_kpw[product] = "Empresarial" && bi_prospect_analysis_kpw[estimated_premium] > 0 && bi_prospect_analysis_kpw[estimated_premium] < 250, "P",
        bi_prospect_analysis_kpw[product] = "Empresarial" && bi_prospect_analysis_kpw[estimated_premium] > 250 && bi_prospect_analysis_kpw[estimated_premium] < 1300, "M",
        bi_prospect_analysis_kpw[product] = "Empresarial" && bi_prospect_analysis_kpw[estimated_premium] > 1300, "G",
        // Engenharia //
        bi_prospect_analysis_kpw[product] = "Riscos de Engenharia" && bi_prospect_analysis_kpw[estimated_premium] = 0, "NA",
        bi_prospect_analysis_kpw[product] = "Riscos de Engenharia" && bi_prospect_analysis_kpw[estimated_premium] > 0 && bi_prospect_analysis_kpw[estimated_premium] < 350, "P",
        bi_prospect_analysis_kpw[product] = "Riscos de Engenharia" && bi_prospect_analysis_kpw[estimated_premium] > 350 && bi_prospect_analysis_kpw[estimated_premium] < 1500, "M",
        bi_prospect_analysis_kpw[product] = "Riscos de Engenharia" && bi_prospect_analysis_kpw[estimated_premium] > 1500, "G",
        // E&O //
        bi_prospect_analysis_kpw[product] = "E&O" && bi_prospect_analysis_kpw[estimated_premium] = 0, "NA",
        bi_prospect_analysis_kpw[product] = "E&O" && bi_prospect_analysis_kpw[estimated_premium] > 0 && bi_prospect_analysis_kpw[estimated_premium] < 20000, "P",
        bi_prospect_analysis_kpw[product] = "E&O" && bi_prospect_analysis_kpw[estimated_premium] > 20000 && bi_prospect_analysis_kpw[estimated_premium] < 100000, "M",
        bi_prospect_analysis_kpw[product] = "E&O" && bi_prospect_analysis_kpw[estimated_premium] > 100000, "G"
    )

enter image description here

enter image description here

Using a measure that simply sums the estimated premium instead of calculating the amounts for the previous year makes the icons show up fine:

enter image description here

How can I get the table to only display entries made on the same period of the previous year (based on my slicer selection) while also being able to display these icons?


Solution

  • It is because you have it as a Calculated Column and it is trying to get this year's Risk Classification versus last year's.

    I'm not sure if the following will work but give it a go. Create a new Measure similar to:

    Risk Classification - Ano Anterior = 
      CALCULATE(
        MIN(bi_prospect_analysis_kpw[Risk Classification]),
        SAMEPERIODLASTYEAR('Calendário'[Date])
      )
    

    And then use this new measure for your Conditional Formatting.