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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
user365576
Frequent Visitor

How can I input the columns of a table to my drop down slicer in Power BI?

Hello,
I am trying to make a drop-down slicer in a report in PowerBi that will contain the columns of a table as parameters. More specifically, when the user chooses one value, then the data of the chosen column will show on the map. However, the table's type of data (Measures) cannot be input in the "Field" of the drop-down slicer. Anyone knows an alternative to input that type of data in the slicer?

2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@user365576 , consider field parameters

 

Power BI Field Parameters — A Quick way for Dynamic Visuals: https://amitchandak.medium.com/power-bi-field-parameters-a-quick-way-for-dynamic-visuals-fc4095ae9af...
Power BI Field Parameters- Measure Slicer and Axis/Dimension slicer: https://youtu.be/lqF3Wa1FllE
Switch TOPN with Field Parameters: https://amitchandak.medium.com/switch-topn-with-field-parameters-299a0ae3725f
Field Parameters- Conditional Formatting
: https://amitchandak.medium.com/field-parameters-conditional-formatting-517aacc23fdf
Power BI Field Parameters, Keep Axis Sort intact| Always Sort on X/Categorial Axis: https://youtu.be/GfBrB6czByw

View solution in original post

v-junyant-msft
Community Support
Community Support

Hi @user365576 ,

@amitchandak ,good answer! That's one possible solution.
And you can try this way:
Create a  new disconnected table by using DAX:

ColumnSelection = DATATABLE("ColumnName", STRING, {{"Column1"}, {"Column2"}, {"Column3"}})

which creates a table with a single column named 'ColumnName' and rows for each column you want to be selectable.

Then use DAX to create a new measure to switch columns dynamically:

DynamicMeasure = 
     VAR SelectedColumn = SELECTEDVALUE(ColumnSelection[ColumnName], "DefaultColumn")
     RETURN
     SWITCH(
         SelectedColumn,
         "Column1", SUM(Table[Column1]),
         "Column2", SUM(Table[Column2]),
         "Column3", SUM(Table[Column3]),
         SUM(Table[DefaultColumn])  // Default case if no selection is made
     )

Replace 'Table[Column1]', 'Table[Column2]', etc., with the actual column references from your data model.

Add the 'ColumnName' field from the disconnected table to a slicer visual on your report and add the 'DynamicMeasure' you created to the map visual. This measure will change based on the slicer selection.

Best Regards,
Dino Tao
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-junyant-msft
Community Support
Community Support

Hi @user365576 ,

@amitchandak ,good answer! That's one possible solution.
And you can try this way:
Create a  new disconnected table by using DAX:

ColumnSelection = DATATABLE("ColumnName", STRING, {{"Column1"}, {"Column2"}, {"Column3"}})

which creates a table with a single column named 'ColumnName' and rows for each column you want to be selectable.

Then use DAX to create a new measure to switch columns dynamically:

DynamicMeasure = 
     VAR SelectedColumn = SELECTEDVALUE(ColumnSelection[ColumnName], "DefaultColumn")
     RETURN
     SWITCH(
         SelectedColumn,
         "Column1", SUM(Table[Column1]),
         "Column2", SUM(Table[Column2]),
         "Column3", SUM(Table[Column3]),
         SUM(Table[DefaultColumn])  // Default case if no selection is made
     )

Replace 'Table[Column1]', 'Table[Column2]', etc., with the actual column references from your data model.

Add the 'ColumnName' field from the disconnected table to a slicer visual on your report and add the 'DynamicMeasure' you created to the map visual. This measure will change based on the slicer selection.

Best Regards,
Dino Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@user365576 , consider field parameters

 

Power BI Field Parameters — A Quick way for Dynamic Visuals: https://amitchandak.medium.com/power-bi-field-parameters-a-quick-way-for-dynamic-visuals-fc4095ae9af...
Power BI Field Parameters- Measure Slicer and Axis/Dimension slicer: https://youtu.be/lqF3Wa1FllE
Switch TOPN with Field Parameters: https://amitchandak.medium.com/switch-topn-with-field-parameters-299a0ae3725f
Field Parameters- Conditional Formatting
: https://amitchandak.medium.com/field-parameters-conditional-formatting-517aacc23fdf
Power BI Field Parameters, Keep Axis Sort intact| Always Sort on X/Categorial Axis: https://youtu.be/GfBrB6czByw

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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