dax for if
1 TopicIf, Or, Else not working
I am working with customer data and I am trying to segment them based on various demographic and lifestage information e.g. if someone is 18-21 years old or 35-39 years old and working full time or partime and not married and does not have kids then they belong to 'segment A' else (a different permutation of the variables above and they fall into 'segment b')etc. I have used If, or, and, then and else but it not producting the right results. I tried using SWITCH but it gave me the " the name 'SWITCH' wasn't recoganised. Make sure it's spelled correctly" error, which I belive has something to do with adding table Vs column. My DAX code looks like below; =if [Q1_Age] = "Under 18" or [Q1_Age] = "18-21" or [Q1_Age] = "22-29" or [Q1_Age] = "30-34" or [Q1_Age] ="35-39" and [#"Q6_Employment_Working full time (30 hours or more work per week)"]=1 or [#"Q6_Employment_Working part time (under 30 hours work per week)"]=1 and [Q2_Parent_None of these apply]=1 and [Q3_Marital_Status] = "Single/Never married" or [Q3_Marital_Status] = "De facto/Living with partner but not married" then "SEGMENT A" else if [Q1_Age] = "Under 18" or [Q1_Age] = "18-21" or [Q1_Age] = "22-29" or [Q1_Age] = "30-34" or [Q1_Age] ="35-39" and [Q3_Marital_Status] = "De facto/Living with partner but not married" or [Q3_Marital_Status] ="Seperated" or [Q3_Marital_Status] ="Divorced" or [Q3_Marital_Status] ="Engaged/Planning to marry" or [Q3_Marital_Status] ="Single/Never married" or [Q3_Marital_Status] ="Married" and [#"Q2_Parent_I have a child/children under 18 living with me"]=1 or [#"Q2_Parent_I have a child/children over 18 living with me"] =1 or [#"Q2_Parent_I have a child/children who have moved out of home"] =1 then "SEGMENT B" else... Can someone guide me on how to identify (or fix) the reason why this is not working, please! Thanks!Solved2.6KViews0likes12Comments