Francesco Mantovani
Francesco Mantovani

Reputation: 12237

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:

enter image description here

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

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?

Upvotes: 1

Views: 1622

Answers (1)

davidebacci
davidebacci

Reputation: 30219

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

Upvotes: 1

Related Questions