Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now
Hi,
I am trying to create a column where I want to create a tag coming from two separate columns. I'm not really sure if the SWITCH function would fit my need. Hoping you could help me on this one. Here's the sample of my table:
From that table, I wanted to create a contactability column where I'm supposed to tag those that have a mobile and email into one. For the picture above, I wanted to tag it as NO EMAIL AND SMS given that the columns Mobile and Email contains NULL.
Hi @Anonymous,
Could you please mark the proper answers as solutions?
Best Regards,
Dale
Hi @Anonymous,
You can use the below Formula to create a new Calculated Column :
Contactability = if(AND(SampleData[Mobile] = "NULL",SampleData[Email] = "NULL"),"NO EMAIL AND SMS", if(and(SampleData[Email] = "NULL",SampleData[Mobile] <> "NULL"),"SMS Only","EMAIL Only"))
If I answer your question! Mark my post as a solution!
Thanks,
Jayant
Hi @Anonymous! Thank you so much for the response. It is finally working. However, how about for instances where one column has a value and the other one has none, how do I code it?
Using the same table, I would also like to tag those with SMS Only, Email Only and with SMS and Email. For SMS only, if there is a mobile number present and the email is NULL and vice versa for Email Only tag. Hope you can help me on this one. Thank you!
Hi @Anonymous,
This Code will cover up all the scenarios:
Contactability = if(AND(SampleData[Mobile] = "NULL",SampleData[Email] = "NULL"),"NO EMAIL AND SMS", if(and(SampleData[Email] = "NULL",SampleData[Mobile] <> "NULL"),"SMS Only","EMAIL Only"))
The above code will cover the Scenario :
The DAX that I have mentioned above contails all the Scenarios, try that in your dataset and see if you Get the result. I tried with the dataset and it is giving me the required result.
If I answer your question! Mark my post as a solution!
Thanks,
Jayant
Hi @Anonymous! What about if Mobile and Email column contains "NULL" where the tag should be No SMS and EMAIL whereas the Mobile and Email column both contains an item and the tag should be With SMS and EMAIL?
@Anonymous,
in that case this should work :
Contactability = if(AND(SampleData[Mobile] = "NULL",SampleData[Email] = "NULL"),"NO EMAIL AND SMS", if(AND(SampleData[Email] = "NULL",SampleData[Mobile] <> "NULL"),"SMS Only",if(AND(SampleData[Email] <> "NULL",SampleData[Mobile] = "NULL"),"EMAIL Only","With SMS and EMAIL")))
If I answer your question! Mark my post as a solution!
Thanks,
Jayant
Hi @Anonymous! it does work but it does not work correctly on all items. Would you know why? I have already treated the data by replacing all the blanks into "NULL" but I still get this.
Can you paste your Data here. So that I can use the same and try code again.
Hi @Anonymous apologies for the late response.
Here you go.
From the table above, I want to tag those that have an email only, sms only, with email and sms and no sms and email.
Hi @Anonymous
I have used your data and applied the sample calculated column that I have applied earlier.
Contactability = if(AND(SampleData[Mobile] = "NULL",SampleData[Email] = "NULL"),"NO EMAIL AND NO SMS", if(AND(SampleData[Email] = "NULL",SampleData[Mobile] <> "NULL"),"SMS Only",if(AND(SampleData[Email] <> "NULL",SampleData[Mobile] = "NULL"),"EMAIL Only","With SMS and EMAIL")))
Thanks,
Jayant
Check out the October 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
116 | |
108 | |
106 | |
93 | |
69 |
User | Count |
---|---|
167 | |
132 | |
130 | |
96 | |
91 |