Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hi i have a column in power query where the data is my sheet name and the names are ABC 2023 and ABC 2023 B2. I want to filter it such that if my source does not have a ABC 2023 B2, it will filter and return only ABC 2023. But if there is a ABC 2023 B2 worksheet then it will give me the one with B2 instead.
i tried using text.contains but my formula is not working
Here's a snapshot of what i meant
Any help is appreciated!
Solved! Go to Solution.
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
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
Try Adding conditonal column in power query
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 19 | |
| 9 | |
| 8 | |
| 7 | |
| 6 |