This is best Fabric, Power BI, SQL and AI community event. How do we know? The last event sold out! Save €200 with code FABCMTY200.
Register nowA 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.
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
Solved! Go to Solution.
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:
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
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
@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.
@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.
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
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:
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
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
@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.
Sign up to receive a private message when registration opens and key events begin.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
| User | Count |
|---|---|
| 32 | |
| 26 | |
| 23 | |
| 20 | |
| 15 |
| User | Count |
|---|---|
| 64 | |
| 41 | |
| 28 | |
| 22 | |
| 22 |