Forum Discussion

AKJB91's avatar
AKJB91
Regular Visitor
2 years ago
Solved

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,

NameIDAreaResult
A100111 - GGT;00112 - GFT;00113 - GTTBoth
B200111 - GGT00111
C300110 - CGTCheck
D400112 - GFT00112
E500111 - GGT;00112 - GFTBoth
F600114 - GHTCheck

 

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

  • Anonymous's avatar
    Anonymous
    2 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 _ Rongtie

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

     

     

     

2 Replies

  • Anonymous's avatar
    Anonymous
    Not 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 _ Rongtie

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

     

     

     

  • 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")