Forum Discussion

jerryr's avatar
jerryr
New Member
2 years ago
Solved

Assign a category based upon a text search in another column

Hi - I am looking to do the following (example):   Table 1 ID Flavor 1 Vanilla 2 Chocolate 3 Rocky Road 4 Cookies and Cream     Table 2 Feedback ID Feedback Text ...
  • AlienSx's avatar
    2 years ago

    jerryr Cholocate <> Chocolate. Other than that 

        Table.AddColumn(
            Table2,
            "Flavor", 
            (w) => 
                try Table1[Flavor]
                    {List.PositionOf(
                        Table1[Flavor], 
                        w[Feedback Text], 
                        Occurrence.First, 
                        (x, y) => Text.Contains(y, x, Comparer.OrdinalIgnoreCase)
                    )}
                otherwise "Unknown"
        )
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi,

    Thanks for the solution AlienSx  provided, and i want to offer some more information for user to refer to.

    hello jerryr , you can add a custom column.

    let a=List.Transform(#"Table 1"[Flavor],each Text.Lower(_)),
    b=Text.Lower([Feedback Text])
    in try Text.Proper( List.Select(a,each Text.Contains(b,_)){0}) otherwise "Unknown"

    Output

    And you can refer to the attachment.

     

    Best Regards!

    Yolo Zhu

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