Forum Discussion
How to filter conditional If in power query
- Anonymous3 years ago
Hi flow12345 ,
My idea is to filter for rows ending in "B2", otherwise filter for shortest character lengths:let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcnRyVjAyMDJWitVBcBScDJViYwE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Custom.Name = _t]), Custom1 = if Table.RowCount(Table.SelectRows(Source, each Text.EndsWith([Custom.Name], "B2"))) < 1 then Table.SelectRows(Source, each Text.Length([Custom.Name]) = List.Min(List.Transform(Source[Custom.Name],each Text.Length(_))) ) else Table.SelectRows(Source, each Text.EndsWith([Custom.Name], "B2")) in Custom1Best Regards,
Gao
Community Support TeamIf there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data in the Power BI Forum
Hi flow12345 ,
My idea is to filter for rows ending in "B2", otherwise filter for shortest character lengths:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcnRyVjAyMDJWitVBcBScDJViYwE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Custom.Name = _t]),
Custom1 = if Table.RowCount(Table.SelectRows(Source, each Text.EndsWith([Custom.Name], "B2"))) < 1 then Table.SelectRows(Source, each Text.Length([Custom.Name]) = List.Min(List.Transform(Source[Custom.Name],each Text.Length(_))) ) else Table.SelectRows(Source, each Text.EndsWith([Custom.Name], "B2"))
in
Custom1
Best Regards,
Gao
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data in the Power BI Forum