Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The FabCon + SQLCon recap series starts April 14th at 8am Pacific. If you’re tracking where AI is going inside Fabric, this first session is a can't miss. Register now

Reply
Toni_LW
Regular Visitor

I need help to create a custom column using an IF statement based on two columns

I'm not sure if this the best solution, I may be making it more complicated than it needs to be.

 

I have two coloumns:

[Dialog identifier]

[Dialog value]

 

Data example:

[Dialog identifier]

111_Menu_80

123_Menu_80

133_Menu_80

111_Menu_87

123_Menu_87

133_Menu_87

 

[Dialog value]

1

2

3

noinput

nomatch

 

If the "Dialog identifier" ends with "80" then:

1 = DEF

2 = STA

noinput = STA

nomatch = STA

 

If the "Dialog identifier" ends with "87" then:

1 = DEF

2 = DEF

3 = STA

noinput = STA

nomatch = STA

 

This is what I was trying to do as a custom column but it doesn't work.... I've also tried a SWITCH function but no joy please help

 

if Text.EndsWith([Dialog identifier]) = “Menu_80” and [Dialog value] = “1” then “Deflection”

 

else if Text.EndsWith([Dialog identifier]) = “Menu_80” and [Dialog value] = “2” then “Spoke to an Agent”

 

else if Text.EndsWith([Dialog identifier]) = “Menu_80” and [Dialog value] = “noinput” then “No Input”

 

else if Text.EndsWith([Dialog identifier]) = “Menu_80” and [Dialog value] = “nomatch” then “No Match”

 

else if Text.EndsWith([Dialog identifier]) = “Menu_87” and [Dialog value] = “1” then “Deflection”

 

else if Text.EndsWith([Dialog identifier]) = “Menu_87” and [Dialog value] = “2” then “Deflection”

 

else if Text.EndsWith([Dialog identifier]) = “Menu_87” and [Dialog value] = “3” then “Spoke to an Agent”

 

else if Text.EndsWith([Dialog identifier]) = “Menu_87” and [Dialog value] = “noinput” then “No Input”

 

else if Text.EndsWith([Dialog identifier]) = “Menu_87” and [Dialog value] = “nomatch” then “No Match”

1 ACCEPTED SOLUTION

@Toni_LW 

Add a custom column in Power Query with the following code. I entered Null at the end if non of the conditions are met, you can replace it with anything:

= let
    identifier = [Dialog identifier],
    value = [Dialog value],
    menu80Condition = Text.EndsWith(identifier, "Menu_80"),
    menu87Condition = Text.EndsWith(identifier, "Menu_87"),

    result = 
        if menu80Condition and value = "1" then "Deflection"
        else if menu80Condition and value = "2" then "Spoke to an Agent"
        else if menu80Condition and value = "noinput" then "No Input"
        else if menu80Condition and value = "nomatch" then "No Match"
        else if menu87Condition and value = "1" then "Deflection"
        else if menu87Condition and value = "2" then "Deflection"
        else if menu87Condition and value = "3" then "Spoke to an Agent"
        else if menu87Condition and value = "noinput" then "No Input"
        else if menu87Condition and value = "nomatch" then "No Match"
        else null
in
    result)
Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

7 REPLIES 7
Fowmy
Super User
Super User

@Toni_LW 

Do you have the both the columns in a single table? Please paste the table as it is:

[Dialog identifier] [Dialog value]

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Both of the columns are in a single table.

@Toni_LW 

Add a custom column in Power Query with the following code. I entered Null at the end if non of the conditions are met, you can replace it with anything:

= let
    identifier = [Dialog identifier],
    value = [Dialog value],
    menu80Condition = Text.EndsWith(identifier, "Menu_80"),
    menu87Condition = Text.EndsWith(identifier, "Menu_87"),

    result = 
        if menu80Condition and value = "1" then "Deflection"
        else if menu80Condition and value = "2" then "Spoke to an Agent"
        else if menu80Condition and value = "noinput" then "No Input"
        else if menu80Condition and value = "nomatch" then "No Match"
        else if menu87Condition and value = "1" then "Deflection"
        else if menu87Condition and value = "2" then "Deflection"
        else if menu87Condition and value = "3" then "Spoke to an Agent"
        else if menu87Condition and value = "noinput" then "No Input"
        else if menu87Condition and value = "nomatch" then "No Match"
        else null
in
    result)
Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Thank you!

VijayP
Super User
Super User

@Toni_LW  Try using this

New Column = SWITCH(TRUE(), RIGHT([[Dialog identifier]]],7)="Menu_80" && 'Table'[Dialog value]]]="1","Deflector",RIGHT([[Dialog identifier]]],7)="Menu_80" && 'Table'[Dialog value]]]="2","Spoke to agent", "others")



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
MY Blog || My YouTube Channel || Connect with me on Linkedin || My Latest Data Story - Ageing Analysis

Proud to be a Super User!


Fowmy
Super User
Super User

@Toni_LW 

Do you need this in Power Query or in Power BI using DAX?

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

I was trying to complete as a power query when you add a custom column.

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.