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
Hi Experts
I cannot work out whats wrong with the following Measure
Criteria
If Worktype = RM and MEUCOMPLIANCEIMPACT = 1 then VAR _A
if Worktype = REMST and MEUCOMPLIANCEIMPACT = 0 the VAR _B
Measure
Sample Data
Count | Worktype | Status | MEUCOMPLIANCEIMPACT |
1 | RW | PPM | 0 |
1 | RW | PPM | 0 |
1 | RW | PPM | 0 |
1 | RW | PPM | 0 |
1 | REMST | PPM | 0 |
1 | REMST | PPM | 0 |
1 | REMST | PPM | 0 |
1 | REMST | PPM | 0 |
Solved! Go to Solution.
@Anonymous
You haven't given the Criteria to the IF statement.
Since you have more than 1 criteria, it may be easier to use a SWITCH:
keep the top part of your measure, but change the RETURN to:
RETURN
SWITCH( TRUE(),
SELECTEDVALUE(Table[Worktype] )= "RM" && SELECTEDVALUE([MEUCOMPLIANCEIMPACT] )= 1 , _A,
SELECTEDVALUE(Table[Worktype] )= "RMST" && SELECTEDVALUE([MEUCOMPLIANCEIMPACT]) = 0 , _B
)
Since it's a measure, you'll need to aggregate the Worktype and MEUCOMPLIANCEIMPACT columns in some way. I chose SELECTEDVALUE, but you could use MAX or SUM depending on how you want it to work.
Copying DAX from this post? Click here for a hack to quickly replace it with your own table names
Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C
I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com
@Anonymous
You haven't given the Criteria to the IF statement.
Since you have more than 1 criteria, it may be easier to use a SWITCH:
keep the top part of your measure, but change the RETURN to:
RETURN
SWITCH( TRUE(),
SELECTEDVALUE(Table[Worktype] )= "RM" && SELECTEDVALUE([MEUCOMPLIANCEIMPACT] )= 1 , _A,
SELECTEDVALUE(Table[Worktype] )= "RMST" && SELECTEDVALUE([MEUCOMPLIANCEIMPACT]) = 0 , _B
)
Since it's a measure, you'll need to aggregate the Worktype and MEUCOMPLIANCEIMPACT columns in some way. I chose SELECTEDVALUE, but you could use MAX or SUM depending on how you want it to work.
Copying DAX from this post? Click here for a hack to quickly replace it with your own table names
Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C
I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com
Hi Allison - firstly thanks for looking at the question but i am getting a blank as th end result when a value is expected
fUll measure
@Anonymous What visual context are you trying to use this in? Try changing the SELECTEDVALUE to max and see if that gives you a result, then you need to understand what that is doing as it may not be what you want (which is why I chose SELECTEDVALUE as I find it better to give blank than an incorrect / misleading result).
You need to make sure that you're using WorkTYPE and MEUCOMPLINCEIMPACT columns in the visual where you're using this measure.
If that still doesn't help, please provide more sample data and include the Date column and any relationships.
Copying DAX from this post? Click here for a hack to quickly replace it with your own table names
Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C
I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com
Hi
No luck with the max and here is the sample data
Sample Data
Count | Worktype | Status | MEUCOMPLIANCEIMPACT |
1 | RW | PPM | 0 |
1 | RW | PPM | 0 |
1 | RW | PPM | 0 |
1 | RW | PPM | 0 |
1 | REMST | PPM | 0 |
1 | REMST | PPM | 0 |
1 | REMST | PPM | 0 |
1 | REMST | PPM | 0
|
@Anonymous
That doesn't look like the raw data, as there are no dates and the 'count' should be a measure, but if you want to use it in a card you need to provide the context within the measure.
Try this:
Copying DAX from this post? Click here for a hack to quickly replace it with your own table names
Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C
I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com
Card visual
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
125 | |
85 | |
69 | |
54 | |
45 |
User | Count |
---|---|
204 | |
106 | |
98 | |
65 | |
54 |