Forum Discussion

mh20221111's avatar
mh20221111
Icon for Helper II rankHelper II
9 months ago
Solved

Apply rule table of multiple string conditions to Data table (issues with List.Contains)

Hi all, I have two tables in Power Query: Rules: columns Seq (unique number) and Condition (a string that contains a logical M expression). Data: the dataset I want to classify. There are mul...
  • AlienSx's avatar
    9 months ago

     

     

     

    let
        seq_no = List.Buffer(conditions[Sequence No]),
        cond = List.Buffer(List.Transform(conditions[Condition], (x) => Expression.Evaluate("each " & x, #shared))),
        cond_column = Table.AddColumn(
            data, 
            "cond",
            (x) => List.Transform(
                List.PositionOf(
                    List.Transform(
                        cond, 
                        (w) => w(x)
                    ), 
                    true,
                    Occurrence.All
                ), 
                (i) => seq_no{i}
            )
        )
    in
        cond_column