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

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

Reply
Manish1198
Helper I
Helper I

Dynamic Column visibility in table visual based on filter selection

In a power bi report, I have a single select country filter and a table visual.
The table visual consists of columns A,B,C,D

When country filter is set to India or Ausralia
I want to show A,B,C,D columns in the table visual.

When country filter is set to USA or Canada
I want to show A,B,C,D,E,F,G columns in the table visual.


Is this possible by any workaround?
Appreciate for your help

2 ACCEPTED SOLUTIONS
Ritaf1983
Super User
Super User

Hi @Manish1198 

To implement dynamic column visibility based on a country selection, use Field Parameters combined with a Measure-based filter. This approach requires a dedicated Dimension Table for countries to ensure reliable filtering and avoid circular dependencies.

1. Data Model Prerequisite
Ensure your model follows a Star Schema:

Dim_Country: A table containing unique country names.

Fact_Table: Your primary data table (Columns A–G).

Relationship: A 1:N relationship from Dim_Country[Country] to Fact_Table[Country].

2. Create the Field Parameter
Navigate to Modeling > New Parameter > Fields.

Select columns A, B, C, D, E, F, and G.

Name the parameter (e.g., DynamicColumns).

This creates a table with an index for each column (0 to 6).

3. Create the Visibility Measure
Create the following DAX measure to control which fields remain visible based on the slicer selection:

קטע קוד
ColumnVisibility =
VAR SelectedCountry = SELECTEDVALUE('Dim_Country'[Country])
VAR CurrentFieldIndex = SELECTEDVALUE('DynamicColumns'[DynamicColumns Order])
RETURN
IF(
ISFILTERED('Dim_Country'[Country]),
SWITCH(TRUE(),
SelectedCountry IN {"India", "Australia"} && CurrentFieldIndex <= 3, 1,
SelectedCountry IN {"USA", "Canada"} && CurrentFieldIndex <= 6, 1,
0
),
1 -- Default view if no country is selected
)
4. Configure the Visual
Add a Slicer using Dim_Country[Country].

Select your Table Visual.

Remove the original columns and add the Field Parameter (DynamicColumns) as the Values.

In the Filters Pane, drag the ColumnVisibility measure into "Filters on this visual".

Set the filter to "is 1" and click Apply filter.

Why this method is optimal:
Performance: Field Parameters are native objects that do not require the overhead of Bookmarks or multiple overlapping visuals.

Scalability: If new countries or columns are added, you only need to update the SWITCH logic in the DAX measure.

Integrity: Using a separate Dim_Country table prevents SELECTEDVALUE from returning blank results due to multiple rows in the fact table.

You can also refer to the linked post with similar scenario:

https://community.fabric.microsoft.com/t5/Desktop/Dynamically-Show-Hide-Columns-and-Rows-Based-on-Si...

The author of the solution also attached the pbix there.

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

View solution in original post

danextian
Super User
Super User

Hi @Manish1198 

You can actually add an extra column to a field parameter table to group the fields into. The fields can have more than one views. You can then use this view column to control the visibility of the fields.

 Let report readers use field parameters to change visuals 

danextian_0-1775616920952.gif

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

7 REPLIES 7
parry2k
Super User
Super User

@Manish1198, do all the columns have some aggregation like sum, avg, in other words, are these numeric columns?



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

parry2k
Super User
Super User

@danextian great solution but doesn't answer the basic question OP posted. 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

danextian
Super User
Super User

Hi @Manish1198 

You can actually add an extra column to a field parameter table to group the fields into. The fields can have more than one views. You can then use this view column to control the visibility of the fields.

 Let report readers use field parameters to change visuals 

danextian_0-1775616920952.gif

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
Ritaf1983
Super User
Super User

Hi @Manish1198 

To implement dynamic column visibility based on a country selection, use Field Parameters combined with a Measure-based filter. This approach requires a dedicated Dimension Table for countries to ensure reliable filtering and avoid circular dependencies.

1. Data Model Prerequisite
Ensure your model follows a Star Schema:

Dim_Country: A table containing unique country names.

Fact_Table: Your primary data table (Columns A–G).

Relationship: A 1:N relationship from Dim_Country[Country] to Fact_Table[Country].

2. Create the Field Parameter
Navigate to Modeling > New Parameter > Fields.

Select columns A, B, C, D, E, F, and G.

Name the parameter (e.g., DynamicColumns).

This creates a table with an index for each column (0 to 6).

3. Create the Visibility Measure
Create the following DAX measure to control which fields remain visible based on the slicer selection:

קטע קוד
ColumnVisibility =
VAR SelectedCountry = SELECTEDVALUE('Dim_Country'[Country])
VAR CurrentFieldIndex = SELECTEDVALUE('DynamicColumns'[DynamicColumns Order])
RETURN
IF(
ISFILTERED('Dim_Country'[Country]),
SWITCH(TRUE(),
SelectedCountry IN {"India", "Australia"} && CurrentFieldIndex <= 3, 1,
SelectedCountry IN {"USA", "Canada"} && CurrentFieldIndex <= 6, 1,
0
),
1 -- Default view if no country is selected
)
4. Configure the Visual
Add a Slicer using Dim_Country[Country].

Select your Table Visual.

Remove the original columns and add the Field Parameter (DynamicColumns) as the Values.

In the Filters Pane, drag the ColumnVisibility measure into "Filters on this visual".

Set the filter to "is 1" and click Apply filter.

Why this method is optimal:
Performance: Field Parameters are native objects that do not require the overhead of Bookmarks or multiple overlapping visuals.

Scalability: If new countries or columns are added, you only need to update the SWITCH logic in the DAX measure.

Integrity: Using a separate Dim_Country table prevents SELECTEDVALUE from returning blank results due to multiple rows in the fact table.

You can also refer to the linked post with similar scenario:

https://community.fabric.microsoft.com/t5/Desktop/Dynamically-Show-Hide-Columns-and-Rows-Based-on-Si...

The author of the solution also attached the pbix there.

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

Thanks, this works as expected. 
Does this setup remove the ability to have totals displayed for a numeric column. Because when I enable the totals, I don't see them. The totals row is missing. 

This is resolved. We need to use the measures here instead of the the numeric columns directly

parry2k
Super User
Super User

@Manish1198 well, one way to do this is to create explicit measures for each column, filter measures based on country, and use these measures instead of columns. It is not a pretty solution, but it will get over the line.

 

 

 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Helpful resources

Announcements
Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.