Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
TLGemp
New 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 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.

1 ACCEPTED 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"

1.png2.png

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

3 REPLIES 3
TLGemp
New Member

 

Source value - the column of des1,des2,des3 can vary and is not always the same

nullnullnullnull
nullnullnullnull
nulldes1nullval1
nulldes2nullval2
nulldes3nullval3

 

Result

des1des2des3
val1val2val3

 

 

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"

1.png2.png

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
v-shex-msft
Community Support
Community Support

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

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Helpful resources

Announcements
July 2024 Power BI Update

Power BI Monthly Update - July 2024

Check out the July 2024 Power BI update to learn about new features.

July Newsletter

Fabric Community Update - July 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors