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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
bhattshubham
Frequent Visitor

Dynamic Columns in table visual based on slicer selection

Hi

I am looking to create a table in PowerBI desktop which should dynamically show columns based on the slicer. i.e If in the Commodity Slicer "Com 1" is selected, the columns corresponding to only Com 1 should show in the table (Com 1 - Attribute 1, Com 1 - Attribute 2). And if "Com 2" is selected in the slicer then only columns corresponding to Com 2 should show in the table ( Com 2 - Attribute 1, Com 2 - Attribute 2, Com 2 - Attribute 3). Please help with suggestions. Below is sample data.

S No.CommodityCom 1 - Attribute 1Com 1 - Attribute 2Com 2 - Attribute 1Com 2 - Attribute 2Com 2 - Attribute 3
1Com 1xxxx(Blank)(Blank)(Blank)
2Com 1xxxx(Blank)(Blank)(Blank)
3Com 1xxxx(Blank)(Blank)(Blank)
4Com 2(Blank)(Blank)xxxxxx
5Com 2(Blank)(Blank)xxxxxx
6Com 2(Blank)(Blank)xxxxxx
7Com 2(Blank)(Blank)xxxxxx
8Com 2(Blank)(Blank)xxxxxx
1 ACCEPTED SOLUTION
v-yalanwu-msft
Community Support
Community Support

Hi @bhattshubham ,  

Currently, slicer cannot based on columns name. To work around this issue, you could Unpivot your table. Please refer to the steps below:

1.Unpivot table(select ColumnCom 1 - Attribute 1” to “Com 2 - Attribute 3”>Unpivot Columns)

v-yalanwu-msft_0-1623048241643.jpeg

2.Remove empty

v-yalanwu-msft_1-1623048241645.jpeg

3.Result

v-yalanwu-msft_2-1623048241650.jpeg

4.Now you can create a matrix and filter your data in slicer by Commodity column.

v-yalanwu-msft_3-1623048241650.pngv-yalanwu-msft_4-1623048241651.png

Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-yalanwu-msft
Community Support
Community Support

Hi @bhattshubham ,  

Currently, slicer cannot based on columns name. To work around this issue, you could Unpivot your table. Please refer to the steps below:

1.Unpivot table(select ColumnCom 1 - Attribute 1” to “Com 2 - Attribute 3”>Unpivot Columns)

v-yalanwu-msft_0-1623048241643.jpeg

2.Remove empty

v-yalanwu-msft_1-1623048241645.jpeg

3.Result

v-yalanwu-msft_2-1623048241650.jpeg

4.Now you can create a matrix and filter your data in slicer by Commodity column.

v-yalanwu-msft_3-1623048241650.pngv-yalanwu-msft_4-1623048241651.png

Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Jihwan_Kim
Super User
Super User

Hi, @bhattshubham 

I am not sure if I understood your question correctly, but I tried to create a sample pbix file like below.

I simplified it a little bit but I hope you can get the concept.

 

Picture2.png

 

Sales by AxisSlicer =
SWITCH (
SELECTEDVALUE ( SlicerTable[Slicer Index] ),
1,
CALCULATE (
SUM ( Sales[Qty] ),
TREATAS ( VALUES ( SlicerTable[Axis] ), Dates[DateAxis] )
),
2,
CALCULATE (
SUM ( Sales[Qty] ),
TREATAS ( VALUES ( SlicerTable[Axis] ), Dates[Week & Year] )
),
3,
CALCULATE (
SUM ( Sales[Qty] ),
TREATAS ( VALUES ( SlicerTable[Axis] ), Dates[Month & Year] )
)
)

 

 

https://www.dropbox.com/s/2t7vxnt9b7cc27s/bhat.pbix?dl=0 

 

Hi, My name is Jihwan Kim.

 

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

 

Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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.

Top Solution Authors
Top Kudoed Authors