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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

conditional formatting based on measurement not working

Having hard time trying to sort this out. I have  a conditional formatting based on a measure but I am getting an anything. 

 

SalesTble (table that contains the main data) 

learn2fly_0-1666201383538.png

Table ThresRefre (table that contains metric thresholds depending on region)

learn2fly_1-1666201463844.png

 

This is my dax code thus far:

 

sales_Threshold
    = CALCULATE (
        IF (
            SUM ( SalesTble[sales] ) >= MIN ( 'ThresRefre'[Upper] )
                && MIN ( ThresRefre[Metric] ) = "sales"
                && VALUES ( 'SalesTble'[Region] ) = MIN ( 'ThresRefre'[Region] ),
            "#5CB85C",
            IF (
                SUM ( SalesTble[sales] ) >= MIN ( 'ThresRefre'[Lower] )
                    && SUM ( SalesTble[sales] ) < MIN ( 'ThresRefre'[Upper] )
                    && MIN ( ThresRefre[Metric] ) = "sales"
                    && VALUES ( 'SalesTble'[Region] ) = MIN ( 'ThresRefre'[Region] ),
                "#F0AD4E",
                IF (
                    SUM ( SalesTble[sales] ) < MIN ( 'ThresRefre'[Lower] )
                        && MIN ( ThresRefre[Metric] ) = "sales"
                        && VALUES ( 'SalesTble'[Region] ) = MIN ( 'ThresRefre'[Region] ),
                    "#D9534F",
                    BLANK ()
                )
            )
        )
    )

 Thank you so much

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

 

According to your screenshot, I couldn't find [Region] columns in 'SalesTble' and 'ThresRefre' tables. And I think there should be something wrong in your code.

Firstly VALUES() will return a table based on 'SalesTble'[Region], however MIN() will return a single value based on 'ThresRefre' [Region], so '=' is not a good idea to compare these two conditions, try "in".

sales_Threshold =
VAR _SALES_UPPER =
    CALCULATE (
        MIN ( 'ThresRefre'[Upper] ),
        FILTER ( 'ThresRefre', ThresRefre[Metric] = "sales" )
    )
VAR _SALES_LOWER =
    CALCULATE (
        MIN ( 'ThresRefre'[Lower] ),
        FILTER ( 'ThresRefre', ThresRefre[Metric] = "sales" )
    )
RETURN
    CALCULATE (
        IF (
            SUM ( SalesTble[sales] ) >= _SALES_UPPER
                && MIN ( ThresRefre[Metric] ) = "sales"
                && MIN ( 'ThresRefre'[Region] ) IN VALUES ( 'SalesTble'[Region] ),
            "#5CB85C",
            IF (
                SUM ( SalesTble[sales] ) >= _SALES_LOWER
                    && SUM ( SalesTble[sales] ) < _SALES_UPPER
                    && MIN ( ThresRefre[Metric] ) = "sales"
                    && MIN ( 'ThresRefre'[Region] ) IN VALUES ( 'SalesTble'[Region] ),
                "#F0AD4E",
                IF (
                    SUM ( SalesTble[sales] ) < _SALES_LOWER
                        && MIN ( ThresRefre[Metric] ) = "sales"
                        && MIN ( 'ThresRefre'[Region] ) IN VALUES ( 'SalesTble'[Region] ),
                    "#D9534F",
                    BLANK ()
                )
            )
        )
    )

If this reply still couldn't help you solve your problem, please share a sample file with me and show me a screenshot with the result you want. This will make it easier for me to find the solution.

 

Best Regards,
Rico Zhou

 

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

1 REPLY 1
Anonymous
Not applicable

Hi @Anonymous ,

 

According to your screenshot, I couldn't find [Region] columns in 'SalesTble' and 'ThresRefre' tables. And I think there should be something wrong in your code.

Firstly VALUES() will return a table based on 'SalesTble'[Region], however MIN() will return a single value based on 'ThresRefre' [Region], so '=' is not a good idea to compare these two conditions, try "in".

sales_Threshold =
VAR _SALES_UPPER =
    CALCULATE (
        MIN ( 'ThresRefre'[Upper] ),
        FILTER ( 'ThresRefre', ThresRefre[Metric] = "sales" )
    )
VAR _SALES_LOWER =
    CALCULATE (
        MIN ( 'ThresRefre'[Lower] ),
        FILTER ( 'ThresRefre', ThresRefre[Metric] = "sales" )
    )
RETURN
    CALCULATE (
        IF (
            SUM ( SalesTble[sales] ) >= _SALES_UPPER
                && MIN ( ThresRefre[Metric] ) = "sales"
                && MIN ( 'ThresRefre'[Region] ) IN VALUES ( 'SalesTble'[Region] ),
            "#5CB85C",
            IF (
                SUM ( SalesTble[sales] ) >= _SALES_LOWER
                    && SUM ( SalesTble[sales] ) < _SALES_UPPER
                    && MIN ( ThresRefre[Metric] ) = "sales"
                    && MIN ( 'ThresRefre'[Region] ) IN VALUES ( 'SalesTble'[Region] ),
                "#F0AD4E",
                IF (
                    SUM ( SalesTble[sales] ) < _SALES_LOWER
                        && MIN ( ThresRefre[Metric] ) = "sales"
                        && MIN ( 'ThresRefre'[Region] ) IN VALUES ( 'SalesTble'[Region] ),
                    "#D9534F",
                    BLANK ()
                )
            )
        )
    )

If this reply still couldn't help you solve your problem, please share a sample file with me and show me a screenshot with the result you want. This will make it easier for me to find the solution.

 

Best Regards,
Rico Zhou

 

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

 

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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