Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now
Hello guys,
trying to figure out what I though is an easy task so I can streamline my queries.
I have two colums I want to use to filter
Column 1: File name:
Column 2: Financial Statement item:
What I want to do is to remove the lines matching following criteria:
AND
I already have a solution to achieve that filtering, via a merch, but that seems too excessive for my goals.
D
I'm a bit late to the party, but I have a different take - it requires a new column but depending on how big your model is, it might be OK.
Create a concatenation of column 1 and 2.
This creates strings like:
unconsolidated Sales Intercompany
unconsolidated Cost Intercompany
In the new column, you can filter for those strings, using the usual Power Query column filter function (no actual coding required).
Cheers
Hey @danielboi ,
create a custom column using an if statement in combination with the function Text.Contains (https://docs.microsoft.com/en-us/powerquery-m/text-contains) like so
if
Text.Contains( [Column1] , "A")
and
(
Text.Contains( [Column2] , "yellow") or Text.Contains( [Column2] , "red")
)
then "omit" else "keep"
Be aware of the brackets.
Then you can use to values to filter the table and remove the column after the filtering.
Hopefully, this provides an idea on how to tackle your challenge.
Regards,
Tom
Hey @danielboi ,
if you are familiar with M and the Advanced Editor you can use this one:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUSpKTVGK1YGwK1NzcvLL4dz0otTUPKXYWAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}, {"Column2", type text}}),
#"onego" =
Table.SelectRows (
#"Changed Type" , (_) =>
( Text.Contains( [Column1] , "A") and
( Text.Contains( [Column2] , "yellow") or Text.Contains( [Column2] , "red") ) = false
)
)
// #"Added Custom" = Table.AddColumn(#"Changed Type", "condition", each if Text.Contains( [Column1] , "A") and
// ( Text.Contains( [Column2] , "yellow") or Text.Contains( [Column2] , "red")
// ) then "omit" else "keep")
in
#"onego"
Regards,
Tom
@danielboi , Not very clear.
Using filters you can get desired output? what is the issue then?
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
91 | |
87 | |
84 | |
68 | |
49 |
User | Count |
---|---|
131 | |
110 | |
96 | |
70 | |
67 |