Forum Discussion
TLGemp
2 years agoNew Member
Use List entry in Table.SelectRows function
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 nece...
- Anonymous2 years ago
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
TLGemp
2 years agoNew Member
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.