Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Anonymous
Not applicable

Conditional Formatting Direct Query Different Tables

Greetings,

I have two columns in a data table in Power BI from different tables using direct query:

  • TableOne[Status]
  • TableTwo[Instances]

I pull TableOne[Status] into the first column and then TableTwo[Instances] and then count the number of statuses based on the instances. The status columns contain Completed, Errored & Running. I want to change the colour of the counts based on the status such as:

  • Completed = Green
  • Running = Grey
  • Errored = Red

Everything I am seeing thus far in Power BI is all about when a value is greater than, other than when the text is equal to X then apply the colour. Any pointers would be greatly appreciated 🙂

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @Anonymous ,

According to your description, I created some data to show:

v-yangliu-msft_0-1608086238899.png

Here are the steps you can follow:

1. Create measure.

Measure =
SWITCH(
    TRUE(),
     MAX('Table'[states])="Completed","Green",
     MAX('Table'[states])="Running","Grey",
     MAX('Table'[states])="Errored","Red"
    )

 2. Find format, search background color in the search bar, find conditional formatting, select the column name to change color, and turn on.

v-yangliu-msft_1-1608086238904.png

3. Select field value in format by and new measure in based on field

v-yangliu-msft_2-1608086238906.png

4. Result.

v-yangliu-msft_3-1608086238908.png

You can downloaded PBIX file from here.

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

Hi  @Anonymous ,

According to your description, I created some data to show:

v-yangliu-msft_0-1608086238899.png

Here are the steps you can follow:

1. Create measure.

Measure =
SWITCH(
    TRUE(),
     MAX('Table'[states])="Completed","Green",
     MAX('Table'[states])="Running","Grey",
     MAX('Table'[states])="Errored","Red"
    )

 2. Find format, search background color in the search bar, find conditional formatting, select the column name to change color, and turn on.

v-yangliu-msft_1-1608086238904.png

3. Select field value in format by and new measure in based on field

v-yangliu-msft_2-1608086238906.png

4. Result.

v-yangliu-msft_3-1608086238908.png

You can downloaded PBIX file from here.

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

Anonymous
Not applicable

Awesome, thank you, this has solved my problem 🙂

Anonymous
Not applicable

Hi  @Anonymous ,

According to your description, I created some data to show:

v-yangliu-msft_0-1606353389616.png

 

Here are the steps you can follow:

1. Create calculated column.

states_id =
SWITCH(
    TRUE(),
    'Table'[states]="Completed",1,
    'Table'[states]="Running",2,
    'Table'[states]="Errored",3)

2. Find format, search background color in the search bar, find conditional formatting, select the column name to change color, and turn off to on.

v-yangliu-msft_1-1606353389623.jpeg

3. The background color interface appears

  • Select format by as rules
  • Change the condition of the following rules to is and number, and select the color
  • After clicking new rule, continue the above operation

v-yangliu-msft_2-1606353389626.jpeg

4. Result.

v-yangliu-msft_4-1606353450344.png

You can downloaded PBIX file from here.

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Thanks,

However, this creates a new column and I already have a column with the counts. Below is my visualization, I want the number of records to be coloured based on the status but each column is from another table. So if the status is Error I want the count to be Green, Amber or Red depending on the string.

ra67052_1-1607905048120.png

 

 

amitchandak
Super User
Super User

@Anonymous , Create a color measure like this and use that in conditional formatting with the field value option

 

switch(true() ,
max(Table[status]) = "Completed" , "Green",
max(Table[status]) = "Running" , "Grey"
max(Table[status]) = "Errored" , "Red"
)

 

steps

https://radacad.com/dax-and-conditional-formatting-better-together-find-the-biggest-and-smallest-numbers-in-the-column
https://docs.microsoft.com/en-us/power-bi/desktop-conditional-table-formatting#color-by-color-values

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Thanks for your reply,

I have since tried to apply this using the links given but the table does not update. Any suggestions?

Helpful resources

Announcements
Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.