Reputation: 63
I have a 2 tables, Table 1 is "Data" and Table 2 is "Rule". How can I apply multiple if condition based on the table condition in Power BI?
Table-Data-(Column A, B and C is my Raw data)
Column A contain Text (Code) Column B contain Number (Usage) Column C contain Text (Usage Unit) Column D output for usage column Column E output for usage Unit column
Note: column D and E my output column based on the column A to C
Table 2- Rule-(This is my condition table for usage and usage unit according to the code
Column A contain the following code "MII", "KKR", "CHE" and "RCB" then usage column can not be blanks or 0 and usage unit column must be blanks for the code "MII" and the remaining codes usage unit can be blanks or the usage unit must be match the following two codes "DMK" or BJP".
Column A contain the following code "001", "KXP", "SRH","DEL" and "RRL" then usage column must be blanks and usage unit column must be blanks as well.
Example;
code Usage UsageUnit Usage(Output) Usage unit(Output)
001 0.00 Okay Okay 001 1.00 DMK Not okay Not okay MII 0.00 BJP Not okay Not Okay MII 1.00 OKAY OKAY
Additional condition for usage columns has 999 then usage output is "xx".
https://www.dropbox.com/s/cozopedtucklomu/CONDITION%20MATCH.xlsx?dl=0 https://www.dropbox.com/s/k68p2mru6yqob6z/CINDITION-MATCH.pbix?dl=0
Upvotes: 0
Views: 974
Reputation: 3741
You can use SWITCH in your CalculatedColumn/Measure. The first argument is TRUE(), second -> our condition evaluated to true, third output, forth, next condition, fifth, output and so on.
SWITCH (
TRUE(),
'DATA'[Code] in {"MII", "KKR", "CHE", "RCB"} && NOT(ISBLANK('DATA'[USAGE]), "ConditionOuptput",
'DATA'[Code] in {"001", "KXP", "SRH","DEL" ,"RRL"} && ISBLANK('DATA'[USAGE]), "SecondConditionOutput",
"Else goes here"
)
Upvotes: 2