March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hey PBI Community,
I've got a few measures that I'm trying to combine into one so I can have a rule that checks values of 1 & 2, and colour values off that.
I have two that do the same thing, just checking different columns, for reference these are:
Checking highest result based of criteria, marking as 1 if result is greater than or equal to the criteria:
Highest =
VAR ThisResult =
MAX (Query1[Result])
VAR Criteria=
MAXX (
ALLSELECTED (Query1[Result]),
CALCULATE (
MAX (Query1[Criteria])
)
)
RETURN
IF (
ThisResult >= Criteria,
1,
0
)
Checks Range against Criteria, if the Range is greater than or equal to Criteria, then 1 else 0.
Range > Criteria=
VAR Criteria =
MAXX (
ALLSELECTED (Query1[Criteria]),
CALCULATE (
MAX (Query1[Criteria])
)
)
VAR Range =
MAXX (
ALLSELECTED (Query1[Range]),
CALCULATE (
MAX (Query1[Range])
)
)
RETURN
IF (
Range >= Criteria,
1,
0
)
These both work with the data that I have, however you can't do a rule based on multiple measures (or so I am led to believe), so I am trying to make both work in the same measure.
I have psuedo that does what I was expecting but it cannot accept multiple IF statements, I have tried ELSE and a comma but I can't figure out if this is correct or not:
ExceedsCheck =
VAR ThisResult =
MAX (Query1[Result])
VAR Criteria=
MAXX (
ALLSELECTED ( Query1[Criteria] ),
CALCULATE (
MAX ( Query1[Criteria] )
)
)
VAR Range=
MAXX (
ALLSELECTED ( Query1[Range] ),
CALCULATE (
MAX ( Query1[Range] )
)
)
RETURN
IF (
Range >= Criteria,
1,
0
)
IF (
ThisResult >= Criteria,
2,
0
)
EDIT: If both have are 1, then 2?
Thanks!
Solved! Go to Solution.
You can do this with if - if you want it to prioritise 1 over 2, then you go:
if (Range>=Criteria, 1,if(ThisResult>=Criteria, 2, 0))
If you want it to prioritise 2 over 1, then reverse the order which it looks at first.
Rather than having the false statement of one of the if statements being 0, stick the other if statement in there instead so it's nested into one statement. You'd need to decide which of 1 or 2 you want to show if both criteria are hit (assuming this is possible in your data model)
Thanks @jthomson I've given this a go and understand where you are trying to advise. I don't think an IF statement is the best for this because there are three possible outcomes.
Are you aware of any DAX syntax that allows for three different outputs? I don't think you can nest an IF three times in DAX as it is true or false?
You can do this with if - if you want it to prioritise 1 over 2, then you go:
if (Range>=Criteria, 1,if(ThisResult>=Criteria, 2, 0))
If you want it to prioritise 2 over 1, then reverse the order which it looks at first.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
23 | |
15 | |
12 | |
9 | |
8 |
User | Count |
---|---|
41 | |
32 | |
29 | |
12 | |
12 |