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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
LockMary
Frequent Visitor

Create a colour visual rule

I am new to PowerBi so please let me know if I need to explain further what I mean.

 

I have created a table that returns from a SS if a rows cell is blank or not. I want to use this as a quick and easy visual using a traffic light system e.g. if all 3 columns return "Yes" I would like this to be highlighted green, if all "No" return Red and if mixed return Yellow/Orange. 

 

The data is coming from a live SS on my companies SharePoint. I have used the below to create the Yes and No

1 Site Owner Exists = VAR MaxBlank = 1

 

RETURN

 

    IF (

 

        CALCULATE (

 

            COUNTBLANK ( [Site Owner (1):] )

 

        ) >= MaxBlank,

 

        "No",

 

        "Yes"

 

    )

 

1 ACCEPTED SOLUTION
v-zhengdxu-msft
Community Support
Community Support

Hi @LockMary 

 

Please try this:

First of all, I create a set of sample data:

vzhengdxumsft_0-1708319882942.png

Then add a measure:

Color = 
VAR _currentColumn1 =
    SELECTEDVALUE ( Data[Column1] )
VAR _currentColumn2 =
    SELECTEDVALUE ( Data[Column2] )
VAR _currentColumn3 =
    SELECTEDVALUE ( Data[Column3] )
RETURN
    IF (
        _currentColumn1 = "Yes"
            && _currentColumn2 = "Yes"
            && _currentColumn3 = "Yes",
        "Green",
        IF (
            _currentColumn1 = "No"
                && _currentColumn2 = "No"
                && _currentColumn3 = "No",
            "Red",
            "Yellow"
        )
    )

Then add a table visual and right click the field, select the conditional formatting > font color

vzhengdxumsft_1-1708320030048.png

Select Field value from the Format style, and choose the color measure in the next checkbox.

vzhengdxumsft_2-1708320142513.png

The result is as follow:

vzhengdxumsft_4-1708320267320.png

 

Best Regards,

Zhengdong Xu

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

3 REPLIES 3
LockMary
Frequent Visitor

Hiya, thank you for this. I thought this would be the solution I was looking for however, I have created measures for my existng columns to return Yes if a contact is listed, and No if a contact is not listed (the idea is to highlight/traffic light the need for a contat to be listed). This means I am unable to use the original columns in the new measure you have listed above and I am unable to reference a measure within a measure. 

 

Could I add new columns that would return the Yes/No values and use the measure you have suggested on that ? 

v-zhengdxu-msft
Community Support
Community Support

Hi @LockMary 

 

Please try this:

First of all, I create a set of sample data:

vzhengdxumsft_0-1708319882942.png

Then add a measure:

Color = 
VAR _currentColumn1 =
    SELECTEDVALUE ( Data[Column1] )
VAR _currentColumn2 =
    SELECTEDVALUE ( Data[Column2] )
VAR _currentColumn3 =
    SELECTEDVALUE ( Data[Column3] )
RETURN
    IF (
        _currentColumn1 = "Yes"
            && _currentColumn2 = "Yes"
            && _currentColumn3 = "Yes",
        "Green",
        IF (
            _currentColumn1 = "No"
                && _currentColumn2 = "No"
                && _currentColumn3 = "No",
            "Red",
            "Yellow"
        )
    )

Then add a table visual and right click the field, select the conditional formatting > font color

vzhengdxumsft_1-1708320030048.png

Select Field value from the Format style, and choose the color measure in the next checkbox.

vzhengdxumsft_2-1708320142513.png

The result is as follow:

vzhengdxumsft_4-1708320267320.png

 

Best Regards,

Zhengdong Xu

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

christinepayton
Super User
Super User

If you give your DAX the hex code for the color you want, you can use the measure directly for the conditional formatting rule. E.g. you could output the color shade of red/green from your if-statement. Here's another post on it with more info: 

 

https://community.fabric.microsoft.com/t5/Desktop/Customized-Conditional-Formatting-Using-DAX/m-p/73...

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.