The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Hi everyone
I need help with a IF statement and measure.
I have this measure,
And this measure on the main table, what i need is to have if the indicator column reads bananas then it should performe the [BANANAS] measure.
Solved! Go to Solution.
Hi @Anonymous
I'll give you some hints. First, get rid of ISERROR. This function is not necessary and, indeed, it's always harmful. Instead of raw division, use the function DIVIDE (this will let you also remove ISERROR). Next, format the code to be human-readable; currently, it's not DAX. Then do not equate a logical function HASONEVALUE to a logical value. This is unnecessary since HASONEVALUE returns a logical value already: TRUE or FALSE. Next, if you have more than 2 conditions to check, use SWITCH instead of IF.
Just please tidy up the code because it's not only ugly. It's unreadable. Such code is not DAX, as Alberto Ferrari and Marco Russo say, and they know very well what they say and why.
I don't know what it is you want to do with [Month Value], so can't help you with it. However, I'd question your decision to make a measure that returns a mixture of different types: a logical value and a numeric value. This is not the correct way to do things.
By the way, if you want to format your code correctly, you can do it here: DAX Formatter by SQLBI
Hi @Anonymous
I'll give you some hints. First, get rid of ISERROR. This function is not necessary and, indeed, it's always harmful. Instead of raw division, use the function DIVIDE (this will let you also remove ISERROR). Next, format the code to be human-readable; currently, it's not DAX. Then do not equate a logical function HASONEVALUE to a logical value. This is unnecessary since HASONEVALUE returns a logical value already: TRUE or FALSE. Next, if you have more than 2 conditions to check, use SWITCH instead of IF.
Just please tidy up the code because it's not only ugly. It's unreadable. Such code is not DAX, as Alberto Ferrari and Marco Russo say, and they know very well what they say and why.
I don't know what it is you want to do with [Month Value], so can't help you with it. However, I'd question your decision to make a measure that returns a mixture of different types: a logical value and a numeric value. This is not the correct way to do things.
By the way, if you want to format your code correctly, you can do it here: DAX Formatter by SQLBI
Hi @Anonymous
Thank you for your reply. indeed this is not the most readble formula, but it was what i got in this project, i have started to change the formula to a better look.
Thank you once more.
User | Count |
---|---|
16 | |
8 | |
7 | |
6 | |
6 |
User | Count |
---|---|
26 | |
13 | |
12 | |
8 | |
8 |