Forum Discussion
Multiple IF statement DAX
- 6 years ago
Are you creating a custom column ? If yes try this code:
IF('Table (3)'[Sale]>=2500 && 'Table (3)'[Sale] <= 3499; "Test-1"; IF('Table (3)'[Sale] >= 3500 && 'Table (3)'[Sale] <= 4999; "Test-2"; IF('Table (3)'[Sale] >= 5000; "Test-3";BLANK())))Ricardo
Another option , that I linke because it is easier to come back later and read is SWITCH. It only works if you know the trick of adding TRUE() as the first entry since it tells it to look for the answer that is true. You can read and see an option with switch here: https://powerpivotpro.com/2015/03/the-diabolical-genius-of-switch-true/
Also, it probably isn't a best practice, but SWITCH exits as soon as it hits the first true, so if you are careful with the order of your switch statement, you don't have to put both ends of every range. The values that previously matched won't be considered for the later tests. Also, you can add one final value with no partner for an else.
Looking at your code, I'm seeing a couple of things, you are using all > signs. Shouldn't the first test be >= 2500 and <=3499? And then the 2nd one <=4999?