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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
jamuka
Helper IV
Helper IV

Filterering Columns with Dynamic Names

Hello all,

 

I have table with product and store information. I transform this table to another table, first grouped based on Product Type, then pivoted it. Then I filtered Product Type Z1  where other Product Types are null.

 

My problem is Product Types are changing and even in some case there's no Z1 Product Type therefore my hardcoded formula gives error.

 

Current Table

 

ProductStoreProduct Type
1X1Z2
1X2Z2
2X1Z1
2X2Z1
3X2Z2
4X1Z3
5X2Z4
2X3Z5
2X5Z7
6X5Z1

 

 

 

Updated Table

ProductZ1Z2Z3Z4Z5Z7
1 X1 - X2    
2X1 - X2   X3X5
3 X2    
4  X1   
5   X2  
6X5     

 

My filtered table should show only Product 6.

 

thanks in advance and happy new year

1 ACCEPTED SOLUTION
slorin
Super User
Super User

@jamuka 

let
Source = YourSource,
Group = Table.Group(Source, {"Product"},
{{"Product Type List", each List.Distinct([Product Type])},
{"Store", each Text.Combine([Store], "-")}}),
Filter = Table.SelectRows(Group, each [Product Type List]={"Z1"})
in
Filter

Stéphane 

View solution in original post

4 REPLIES 4
slorin
Super User
Super User

@jamuka 

let
Source = YourSource,
Group = Table.Group(Source, {"Product"},
{{"Product Type List", each List.Distinct([Product Type])},
{"Store", each Text.Combine([Store], "-")}}),
Filter = Table.SelectRows(Group, each [Product Type List]={"Z1"})
in
Filter

Stéphane 

thank you for your help @slorin 

 

regards

Cem

jamuka
Helper IV
Helper IV

Hi @slorin,

 

thank  you for your help, your code works but if a product have two different store it didn't combine stores and

didn't show it in final table.

 

Current Table

ProductStoreProduct Type
2X1Z1
2X2Z1

 

 

Updated Table

ProductZ1
2X1 - X2

 

my current (hard coded) formula is

 

 

let
    Source = YourSource
    
	#"Grouped Rows" = Table.Group(#"Source", {"Product", "Product Type"}, {{"Table", each Text.Combine([Store],"-"), type nullable text}}),

	#"Pivoted Column" = Table.Pivot(#"Grouped Rows", List.Distinct(#"Grouped Rows"[#"Product Type"]), "Product Type", "Table"),
    
	#"Filtered Rows" = Table.SelectRows(#"Pivoted Column", each ([Z1] <> null) and ([Z2] = null) and ([Z3] = null) and ([Z4] = null) and ([Z5] = null) and ([Z7] = null))

in
    #"Filtered Rows"

 

 

kind regards

Cem

 

 

slorin
Super User
Super User

Hi @jamuka 

 

let
Source = YourSource
Group = Table.Group(Source, {"Product"}, {{"Product Type List", each [Product Type]}, {"Data", each _}}),
Filter = Table.SelectRows(Group, each [Product Type List]={"Z1"}),
Combine = Table.Combine(Filter[Data])
in
Combine 

Stéphane 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.