Forum Discussion
IF condition returns DAX error
- 6 years ago
Anonymous ,
Yes MAX() is correct. You are asking the engine to make a decision based on your field value, yes? How does DAX "know" which row in that field is the one to use? Row 1? Row 2? etc.
Until you place it on a something that filters all the values down to one, you are trying to give it multiple values. However when you place it on a matrix, there is only one value, the value from that row.
Let me recommend Supercharge Power BI by MattAllington
Let me know if you have any questions.
If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos are nice too.
Nathaniel
Hi Anonymous ,
What do you mean you are not aggregating anything in a string field?
Nathaniel
- Nathaniel_C6 years ago
Community Champion
Hi Anonymous ,
I think I see what you mean. When you write a formula in a calculated column the engine knows which row you are on. However when you write a measure, the engine does not know where you are applying the measure until you do. Therefore it will not accept the formula. However if you add a max, it will know to which value to use in this formula, the (in this case) maximum value. Then it knows whether to return a true or false. Then when you apply this to for instance a matrix, it looks a the row filter and can apply it to that value or apply it to once again using the maximum when you are doing the total because there is no filter then.
Let me know if you have any questions.
If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos are nice too.
Nathaniel- Anonymous6 years agoNot applicable
Thanks for your help. Let me be more clear on my request. I am looking for another way to write this in DAX where I do not have to use the MAX function or is MAX correct for this? This is a common query.
If my field value = XXXX then do this formula
if my field value = YYYY then do this formula
It does not seem right having to use the MAX function but maybe it is???
- Nathaniel_C6 years ago
Community Champion
Anonymous ,
Yes MAX() is correct. You are asking the engine to make a decision based on your field value, yes? How does DAX "know" which row in that field is the one to use? Row 1? Row 2? etc.
Until you place it on a something that filters all the values down to one, you are trying to give it multiple values. However when you place it on a matrix, there is only one value, the value from that row.
Let me recommend Supercharge Power BI by MattAllington
Let me know if you have any questions.
If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos are nice too.
Nathaniel