I want to change the background colors using DAX measure in conditional formatting

Viewed 923

I am new to DAX and wanted solution for the following report.

Data input Output

I want to change the background color using DAX measure in conditional formatting in my report. The lookup column is "Column2"

1 Answers

This functionality is inbuilt in Power bi.

Method 1

  1. Select the table
  2. in the menu select Conditional formatting

enter image description here

  1. Pick the column

enter image description here

  1. Turn on the Background color and click on Advance control

enter image description here

  1. Configure the fields as follows
  • From the drop down menu Formatted by choose Rules
  • For base on fields pick the column again from the drop down
  • For summarization pick average
  • In the rules create the rules that you required
  • Add a new rule click on + New Rule button

enter image description here

Method 2

Create below measure

COLOUR EQUAL ROW = 
IF (
    HASONEVALUE ( 'DIM Hospital'[hospital_id] ),
    IF (
        MAX ( 'DIM Hospital'[hospital_id] ) <= 2,
        "lightgreen",
        IF (
            MAX ( 'DIM Hospital'[hospital_id] ) <= 5,
            "blue",
            IF ( MAX ( 'DIM Hospital'[hospital_id] ) <= 20, "orange", "white" )
        )
    ),
    BLANK ()
)

For configuring please choose the respective column and configure the formatting as below.

enter image description here

Sample below. enter image description here

Related