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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
srigag900
Frequent Visitor

Need to apply a conditional formatting to the fist level if the second level has a negative value

Hi Everyone,

 

Im currenly facing a serious challenge in Power Bi on applying conditional formating to the first level if the second level has a negative figure. I will give you a snapsot in here

srigag900_0-1757246487893.png

In the above table, i need to color colombo,1006 code which is 53 and Kandy i006 which is 33. If the value flagged in red, then he can drill down fro further analysis. The issue is this. Name, and size (second level) are coming from a different tables.value is coming from three different tables. which is aggregated already. and the location (in columns) are coming from another table.

is there any way to fix this issue? 

2 ACCEPTED SOLUTIONS
danextian
Super User
Super User

Hi @srigag900 

In a measure, create a virtual summary of the second level column and the value, filter the summary to < 0 and then count the rows. If the count isn't blank and the row isn't level 2, then return the color

Color =
VAR _count =
    COUNTROWS (
        FILTER (
            SUMMARIZECOLUMNS ( Subcategory[Subcategory], "@value", [Sum of Value] ),
            [@value] < 0
        )
    )
RETURN
    IF (
        NOT ( ISBLANK ( _count ) ) && NOT ( ISINSCOPE ( Subcategory[Subcategory] ) ),
        "#fdaaaa"
    )

 

danextian_1-1757248999706.png

Please see the attached pbix.

 

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

Jihwan_Kim
Super User
Super User

Hi,

I do not know how your semantic model looks like, but I tried to create a sample pbix file like below.

Please check the below picture and the attached pbix file.

 

Jihwan_Kim_1-1757249406209.png

 

 

Jihwan_Kim_0-1757249361165.png

Value total: = 
SUM(data[value])

 

cf measure: = 
VAR _condition =
    IF (
        SUMX (
            ADDCOLUMNS (
                VALUES ( Category[category] ),
                "@condition", IF ( [Value total:] < 0, -1 )
            ),
            [@condition]
        ) < 0,
        -1
    )
RETURN
    SWITCH (
        TRUE (),
        ISINSCOPE ( Category[category] ), IF ( [Value total:] < 0, -1 ),
        ISINSCOPE ( 'Name'[name] ), _condition
    )

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

2 REPLIES 2
Jihwan_Kim
Super User
Super User

Hi,

I do not know how your semantic model looks like, but I tried to create a sample pbix file like below.

Please check the below picture and the attached pbix file.

 

Jihwan_Kim_1-1757249406209.png

 

 

Jihwan_Kim_0-1757249361165.png

Value total: = 
SUM(data[value])

 

cf measure: = 
VAR _condition =
    IF (
        SUMX (
            ADDCOLUMNS (
                VALUES ( Category[category] ),
                "@condition", IF ( [Value total:] < 0, -1 )
            ),
            [@condition]
        ) < 0,
        -1
    )
RETURN
    SWITCH (
        TRUE (),
        ISINSCOPE ( Category[category] ), IF ( [Value total:] < 0, -1 ),
        ISINSCOPE ( 'Name'[name] ), _condition
    )

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
danextian
Super User
Super User

Hi @srigag900 

In a measure, create a virtual summary of the second level column and the value, filter the summary to < 0 and then count the rows. If the count isn't blank and the row isn't level 2, then return the color

Color =
VAR _count =
    COUNTROWS (
        FILTER (
            SUMMARIZECOLUMNS ( Subcategory[Subcategory], "@value", [Sum of Value] ),
            [@value] < 0
        )
    )
RETURN
    IF (
        NOT ( ISBLANK ( _count ) ) && NOT ( ISINSCOPE ( Subcategory[Subcategory] ) ),
        "#fdaaaa"
    )

 

danextian_1-1757248999706.png

Please see the attached pbix.

 

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors
Top Kudoed Authors