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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

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
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors
Top Kudoed Authors