Forum Discussion
two or more IF conditions
- 3 years ago
EDIT: in Power Query I've made it now that way as an example:
Hi,
I am not sure if I understood your question correctly, but please try something like below.
It is for creating a calculated column.
Expected result Calculated Column: =
SWITCH (
TRUE (),
Persons[Age] > 10
&& Persons[Age] <= 20, "BETWEEN 10-20",
Persons[Age] > 20
&& Persons[Age] <= 30, "BETWEEN 20-30",
Persons[Age] > 30
&& Persons[Age] <= 40, "BETWEEN 30-40"
)
Hi,
thanks for the quick response but I get the same error as above. Let me try to explain it better:
My goal is to be able to add a new coloumn via Power Query OR via a measure! I'm in the learning phase and just started with power BI.
Power Query: I want to add a custom coloum to my table:
But PQ doesn't know what SWITCH is!
Also I want to be able to add a new coloumn via a meassure but I think in the statement is something missing lik ADDCOLOUMN.
Sorry, I can't explain it better.
Regards,
Tim
- JirkaZ3 years ago
Solution Specialist
The SWITCH() function is a DAX function - therefore will not work in Power Query, but it will work when creating a calculated column in the report engine.
If you want to use Power Query, then you'll have to use multiple embedded if then else statements