Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.
Check it out now!Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more
Hello everybody.
I have a problem in using a List as argument for a column/record in the function Table.SelectRows.
From my source I got TABLE where one COLUMN, eg. Column3, contains all necessary information. The challenge is that the column I am looking for is not always Column3. It can be also Column4 or Column5. I managed to find a way that I got back the correct column name in a LIST. Now I want to use this LIST entry in the Table.SelectRows function to get rid of all other unwanted stuff. But this do not want to work.
= Table.SelectRows(Source, each ([Referenz by using the LIST] = "Value for Filtering"))
So, what will be the step to go from e.g. {Column3} to the Source[Column3] referenz.
Thanks.
Solved! Go to Solution.
Hi @TLGemp,
Here is query table code that I used to transform table structure based on 'transpose table' and 'remove blank row' functions to output expected table structure without specific column names as conditions, you can try it if helps:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WUtKBoVgdLLyU1GJDiEhZYo4hkqgRXNQISdQYLmqsFBsLAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t, Column3 = _t, Column4 = _t]),
#"Removed Blank Rows" = Table.SelectRows(Source, each not List.IsEmpty(List.RemoveMatchingItems(Record.FieldValues(_), {"", null}))),
#"Transposed Table" = Table.Transpose(#"Removed Blank Rows"),
#"Removed Blank Rows1" = Table.SelectRows(#"Transposed Table", each not List.IsEmpty(List.RemoveMatchingItems(Record.FieldValues(_), {"", null}))),
#"Promoted Headers" = Table.PromoteHeaders(#"Removed Blank Rows1", [PromoteAllScalars=true]),
#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"des1", type text}, {"des2", type text}, {"des3", type text}})
in
#"Changed Type"
Regards,
Xiaoxin Sheng
Source value - the column of des1,des2,des3 can vary and is not always the same
null | null | null | null |
null | null | null | null |
null | des1 | null | val1 |
null | des2 | null | val2 |
null | des3 | null | val3 |
Result
des1 | des2 | des3 |
val1 | val2 | val3 |
let
Quelle = Excel.CurrentWorkbook(){[Name="Tabelle4"]}[Content],
#"Geänderter Typ" = Table.TransformColumnTypes(Quelle,{{"Column1", type any}, {"Column2", type text}, {"Column3", type any}, {"Column4", type text}}),
#"Tiefer gestufte Header" = Table.DemoteHeaders(#"Geänderter Typ"),
#"Transponierte Tabelle" = Table.Transpose(#"Tiefer gestufte Header"),
#"Gefilterte Zeilen" = Table.SelectRows(#"Transponierte Tabelle", each ([Column4] = "Des1")),
Column1 = #"Gefilterte Zeilen"[Column1],
Benutzerdefiniert1 = Table.SelectRows(Quelle, each ([Column2] <> null))
in
Benutzerdefiniert1
In the line Benutzerdefiniert1 I would like to use the list Column1 from the line above instead of the static [colum2]. This should make the code more dynamic.
Hi @TLGemp,
Here is query table code that I used to transform table structure based on 'transpose table' and 'remove blank row' functions to output expected table structure without specific column names as conditions, you can try it if helps:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WUtKBoVgdLLyU1GJDiEhZYo4hkqgRXNQISdQYLmqsFBsLAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t, Column3 = _t, Column4 = _t]),
#"Removed Blank Rows" = Table.SelectRows(Source, each not List.IsEmpty(List.RemoveMatchingItems(Record.FieldValues(_), {"", null}))),
#"Transposed Table" = Table.Transpose(#"Removed Blank Rows"),
#"Removed Blank Rows1" = Table.SelectRows(#"Transposed Table", each not List.IsEmpty(List.RemoveMatchingItems(Record.FieldValues(_), {"", null}))),
#"Promoted Headers" = Table.PromoteHeaders(#"Removed Blank Rows1", [PromoteAllScalars=true]),
#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"des1", type text}, {"des2", type text}, {"des3", type text}})
in
#"Changed Type"
Regards,
Xiaoxin Sheng
Hi @TLGemp ,
Can you please share a pbix or some dummy data that keep the raw data structure with expected results? It should help us clarify your scenario and test to coding formula.
How to Get Your Question Answered Quickly
Regards,
Xiaoxin Sheng