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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
sbarnhill75
Frequent Visitor

Check if value within spec limit

Hello - 

I have a 'Product' table with all of the products and then a column for their [Min Temperatures] and another column of [Max Temperatures].  Between the min and max temps is an acceptable range.  Then I have another table with hourly actual readings 'Details'.  This has a [Date Time], [Product] and [Temperature] column.  The two tables are joined by the [Product] and everything works okay.  If I just pull in the min and max columns to the details table it appears how I expect it to.

 

What I cannot seem to do is figure out a DAX formula to use for conditional formatting on the 'Details'[Temperature] column.  I want to show this as red if over max or blue if under min.  Basically I've been trying something like this:  if('Details'[Temperature]<'Products'[Min temperature],1, if('Details'[Temperature]>'Products'[Max temperature],2,3)).  It doesn't matter if it is a measure or a calculated column but everything I try doesn't seem to work.

 

Thank you - 

Sara

1 ACCEPTED SOLUTION

This is what we ended up getting to work and maybe it will be helpful to someone else.

=
VAR MAXVal = IF(ISBLANK(RELATED('Products'[PR_MAX_Temp])), 10000, RELATED('Products'[PR_MAX_Temp]))
RETURN
IF(
('Details'[Temperature]) > MAXVal, "#FF0000",
IF((('Details'[Temperature]) < RELATED('Products'[PR_MIN_Temp])), "#0000FF", "#198c19"))

 

View solution in original post

5 REPLIES 5

Hi @sbarnhill75 ,

you must specify in the formula how the values are to be aggregated, if necessary. I would work here with MIN and MAX. You can already specify the color here as a HEX code.

 

CF Temperature =
IF (
    MAX ( Details[Temperature] ) > MAX ( 'Product'[Max Temperatures] ),
    "#FF0000",
    IF (
        MIN ( Details[Temperature] ) < MIN ( 'Product'[Min Temperatures] ),
        "#0000FF",
        BLANK ()
    )
)

 

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast


That did not seem to work.  I thought that it might work because it was different than the combinations I've been trying.  I'm working in Visual Studio so I didn't use the HEX code parts, but ended up entering in the formula like this:  

Temp in Range2:=IF(

MAX('Details'[Temperature]) > MAX('Products'[PR_MAX_T]), 1,
IF(MIN('Details'[Temperature]) < MIN('Products'[PR_MIN_T]), 2,
3))

 

And here are my results...

sbarnhill75_0-1625759417849.png

 

the PR_MIN_T AND PR_MAX_T are the ranges for those products

 

 

Hi, @sbarnhill75 

Try calculated columns as below:

Max_Tem = RELATED('Product'[Max Temperatures]) 
Min_Tem = RELATED('Product'[Min Temperatures]) 
conditional formatting =
SWITCH (
    TRUE (),
    Details[Temperatures] > Details[Max_Tem], "orange red",
    Details[Temperatures] < Details[Min_Tem], "light blue",
    "light yellow"
)

Best Regards,
Community Support Team _ Eason

Hi @sbarnhill75 ,

 

can you share a screenshot of the data model and data in the data view?

 

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast


This is what we ended up getting to work and maybe it will be helpful to someone else.

=
VAR MAXVal = IF(ISBLANK(RELATED('Products'[PR_MAX_Temp])), 10000, RELATED('Products'[PR_MAX_Temp]))
RETURN
IF(
('Details'[Temperature]) > MAXVal, "#FF0000",
IF((('Details'[Temperature]) < RELATED('Products'[PR_MIN_Temp])), "#0000FF", "#198c19"))

 

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.