Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Power BI :: change background color based on another column

I previously asked a question about how to use PREVIOUSMONTH and thanks to that I was able to create 2 columns:

  • first one with the current month spending per resource on Azure
  • second one with the same resources on the previous month:

enter image description here

I now would like to change the background color so the number could be:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

  • **Red ** if the cost has increased
  • **Green ** if the cost has decreased
  • **Yellow ** if the price is the same

Like this:

enter image description here

I checked into Conditional Formatting > Background Color but I think there is no option for doing that.

So I created this DAX rule:

PreviousMonthCheck = 
IF ([PreviousMonth] < MAX('Usage details'[costInBillingCurrency]),1,
    IF ([PreviousMonth] = MAX('Usage details'[costInBillingCurrency]),2,
        IF ([PreviousMonth] > MAX('Usage details'[costInBillingCurrency]),3,
            "Fourth case"
        )
    )
)

Now, how to use this rule to color the SelectedMonth?

Or is there any Visual that could do that out-of-the-box?

>Solution :

For this, you can do it with native visuals. In the custom formatting, choose Rules and then reference your measure. Add the 3 rules as below.

BTW, your measure can and should be simplified using the SWITCH(TRUE()) pattern.

enter image description here

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading