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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
v-yangliu-msft
Community Support
Community Support

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
v-yangliu-msft
Community Support
Community Support

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 🙂

v-yangliu-msft
Community Support
Community Support

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

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.