Forum Discussion
conditional formatting based on measurement not working
- Anonymous3 years ago
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 ZhouIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
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.