Forum Discussion
g-wizard
2 years agoFrequent Visitor
DAX calculation-IF/AND/OR
Hello I am getting stuck on this calc that i had in tableau.
Could any support me in converting this to dax?
IIF(([Campaign Type]="ZKMT" AND [Cust Flag]="O") OR ([Campaign Type]="ZDDK" AND [Cust Flag]="O") OR ([Campaign Type]="ZMDK" AND [Cust Flag]="O") OR ([Campaign Type]="ZVDK" AND [Cust Flag]="O"),[CRM_CAMPAIGN_ID],NULL)
g-wizard ,
Recommend using SWITCH Statement as follows:
= SWITCH( TRUE(), AND( [Campaign Type]="ZKMT", Cust Flag]="O" ), [CRM_CAMPAIGN_ID], AND( [Campaign Type]="ZDDK", Cust Flag]="O" ), [CRM_CAMPAIGN_ID], AND( [Campaign Type]="ZMDK", Cust Flag]="O" ), [CRM_CAMPAIGN_ID], BLANK() )There are other ways this can be written, but I find this method keeps your conditions more clear and concise.
Hope this helps.
Regards,
4 Replies
- rsbinCommunity Champion
g-wizard ,
Recommend using SWITCH Statement as follows:
= SWITCH( TRUE(), AND( [Campaign Type]="ZKMT", Cust Flag]="O" ), [CRM_CAMPAIGN_ID], AND( [Campaign Type]="ZDDK", Cust Flag]="O" ), [CRM_CAMPAIGN_ID], AND( [Campaign Type]="ZMDK", Cust Flag]="O" ), [CRM_CAMPAIGN_ID], BLANK() )There are other ways this can be written, but I find this method keeps your conditions more clear and concise.
Hope this helps.
Regards,