Forum Discussion
Conditional Column with Multiple Conditions
Hi All,
I am looking for a little help to develop a conditional column which would tag the rows I have in my table dependant on what a certain column contains.
Say I have 3 columns and I am looking to develop the 4th column below where the rules are;
If Column "Area" contains 00111 & 00112 then "Both"
If Column "Area" contains 00111 then "00111"
If Column "Area" contains 00112 then "00112"
Else "Check"
See below example,
| Name | ID | Area | Result |
| A | 1 | 00111 - GGT;00112 - GFT;00113 - GTT | Both |
| B | 2 | 00111 - GGT | 00111 |
| C | 3 | 00110 - CGT | Check |
| D | 4 | 00112 - GFT | 00112 |
| E | 5 | 00111 - GGT;00112 - GFT | Both |
| F | 6 | 00114 - GHT | Check |
I have attempted a number of formulas (IF statements & also conditional columns) but have not been able to find a suitable fix. It is the "Both" rule that I am struggling with as my approach appears to tag anything containing 00111 or 00112 as "Both" and I cannot find a way to add multiple rules via the conditional column option in transform data.
Any help greatly appreciated.
Thanks,
AB
- Anonymous2 years ago
Hi AKJB91 ,
Please have a try.
Add a custom column.
if Text.Contains([Area], "00111") and Text.Contains([Area], "00112") then "Both" else if Text.Contains([Area], "00111") then "00111" else if Text.Contains([Area], "00112") then "00112" else "Check"How to Get Your Question Answered Quickly - Microsoft Fabric Community
If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .
Best Regards
Community Support Team _ RongtieIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
2 Replies
- AnonymousNot applicable
Hi AKJB91 ,
Please have a try.
Add a custom column.
if Text.Contains([Area], "00111") and Text.Contains([Area], "00112") then "Both" else if Text.Contains([Area], "00111") then "00111" else if Text.Contains([Area], "00112") then "00112" else "Check"How to Get Your Question Answered Quickly - Microsoft Fabric Community
If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .
Best Regards
Community Support Team _ RongtieIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- sandra1982New Member
Hello
Can someone help with the below formula, it gives me null everywhere in the column
= Table.AddColumn(#"Renamed Columns3", "Churn flag NEW", each if([Seniority group]="0-1 year" & [Reason for Action]="Termination") then "Churn" else "null")