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
Anonymous
Not applicable

How could implement selecting columns which shows in table dynamically?

Hi,

I have requirment as follow:

we have a table :

A1A2A3M1M2M3
      
      
      
      

we need to give to user possibility to select A1, A2,A3 to show in the table or not.

I found this link :https://community.powerbi.com/t5/Desktop/Select-columns-to-show-on-table-visual/m-p/606363/highlight...

But in this link the attributes(A1,A2,A3 )were put rows, but I need them as column.

I appreciate any suggestion and help on this problem.

Thank you.

Regards,

Matin 

1 ACCEPTED SOLUTION

@Anonymous  It is a bit unconventional but you can try to unpivot all the A and M columns, so that you are left with: 

C, Attribute, Value

 

Also create a disconnected table (no relationships to current data model) for the M values that you want user to select. I called this table Slicer.

Slicer:

Select
M1
M2
M3

 

Then create the matrix with C in Rows, Attribute in Columns, Value in Values.

 

Finally, create this measure to filter the Attribute: 

 

ShowColumns =
Var SlicerSelection = VALUES(Slicer[Select])
Var AlwaysShow = {("A1"), ("A2"), ("A3")}
Var ShowValues = UNION(SlicerSelection, AlwaysShow)
RETURN
IF(SELECTEDVALUE('Table'[Attribute]) IN ShowValues, 1, 0)
 
Put a filter on the visual for Attribute using Top N and use the ShowColumns measure as the By Value to filter for Top 1.

Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

View solution in original post

15 REPLIES 15
Anonymous
Not applicable

Thank you @AllisonKennedy  for the solution .

I follow the steps but the value of measure is always 0! and the solution does not work.
here are my tables :

Matsa_0-1595330654852.png

and I created measure as follow:

ShowColumns =
Var SlicerSelection = VALUES(Slicer[Column1])
Var AlwaysShow = {("A1"); ("A2"); ("A3")}
Var ShowValues = UNION(SlicerSelection; AlwaysShow)
RETURN
IF(SELECTEDVALUE('Table'[Attribute]) IN ShowValues; 1; 0)
do you have any Idea?
I appreciate your help on this matter.
Regards,
Matin

How have you configured the matrix visual? The measure will only work if there is only 1 Attribute selected, so you need to have attribute in Columns in the Matrix, and put this measure as the visual level filter as I explained in my previous reply, as a 'top N' filter. Can you share image of your report visual page Visualizations and Filters Pane to see what fields you've put in the visual? Redact any confidential info from the visual.

Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Anonymous
Not applicable

@AllisonKennedy 

here is my Matrix configuration and Filter :

Matsa_0-1595332069319.png

 

Make sure the Top N is set to Top 1. Sorry I should have specified in original post. I have updated now.

Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Anonymous
Not applicable

@AllisonKennedy , even with Top 1 does not work.

here is the result, as you could see the measure returns 1 for A1,A2,A3 ( which I want to be selacteble), and 0 for M1, M2 and M3.

and infact Slider does not doing anything .

Matsa_0-1595333603884.png

for sure I did something wrong but I could not find it 😞

Sorry, I did it the other way around and made M1, M2, M3 selectable. Just update the measure to replace A1, A2, A3 with M1, M2, M3:

ShowColumns =
Var SlicerSelection = VALUES(Slicer[Column1])
Var AlwaysShow = {("M1"); ("M2"); ("M3")}
Var ShowValues = UNION(SlicerSelection; AlwaysShow)
RETURN
IF(SELECTEDVALUE('Table'[Attribute]) IN ShowValues; 1; 0)

Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Anonymous
Not applicable

Thank @AllisonKennedy , now it works.

I really appreciate your help .

Regards,

Matsa

AllisonKennedy
Super User
Super User

Use a matrix instead of a table, and put the attributes in 'columns' field and turn 'show on rows' to ON. https://powerbi.microsoft.com/en-us/blog/power-bi-desktop-august-2017-feature-summary/#valuesOnRows

Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Anonymous
Not applicable

Thank you @amitchandak , it is very useful, but still there is a problem.

I need to make A1,A2,A3 selectable and always show M1 and M2 and M3 .
But when I added M1,M2 and M3 to Matrix as columns , they don't add to matrix.
do you have any suggestion to solve this problem?

sorry maybe my questions are so basic, because I am beginners in Power BI

Regards,

Matin 

Hi @Anonymous ,

 

What problem have you met? You just need to do like this.

1. Unpivot the columns.

v-lionel-msft_0-1594621010903.png

2. Add the columns to the matrix.

v-lionel-msft_1-1594621069052.png

 

Best regards,
Lionel Chen

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

 

 

Anonymous
Not applicable

Thanks @v-lionel-msft  for the explanation,But this is not what I need.

I have a table like this:

CA1A2A3M1M2M3
       
       
       
       
       
       

and I need to show it as it is , but I need to put  a slider in order to give possibility to select or not select A1,A2,A3.

I did unpivot the columns A1,A2 and A3.

I put attribute as a slider and in Matrix:

C,M1,M2,M3 as ROWS

Attribute as columns

Values: first value 

But My result is like this:

CM1M2M3A1A2A3
       
       
       
       
       
       

and A1,A2 and A3 are selectable.

Do you have any suggestion in order to solve my problem?

Thank you in advance.

Regards.

Matin

Hi @Anonymous ,

 

Try to unpivot A1, A2 and A3 columns, then, you can get such a table.

v-lionel-msft_1-1594719750306.png

And add columns to the matrix.

 

v-lionel-msft_0-1594719734779.png

 

Best regards,
Lionel Chen

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

Anonymous
Not applicable

Thanks @v-lionel-msft ,the steps which you mentioned is what I did( as I explained before), but the result is not similar to what I want, I need the result as follow:

CA1A2A3M1M2M3
       
       
       

 

Regards,

Matin 

@Anonymous  It is a bit unconventional but you can try to unpivot all the A and M columns, so that you are left with: 

C, Attribute, Value

 

Also create a disconnected table (no relationships to current data model) for the M values that you want user to select. I called this table Slicer.

Slicer:

Select
M1
M2
M3

 

Then create the matrix with C in Rows, Attribute in Columns, Value in Values.

 

Finally, create this measure to filter the Attribute: 

 

ShowColumns =
Var SlicerSelection = VALUES(Slicer[Select])
Var AlwaysShow = {("A1"), ("A2"), ("A3")}
Var ShowValues = UNION(SlicerSelection, AlwaysShow)
RETURN
IF(SELECTEDVALUE('Table'[Attribute]) IN ShowValues, 1, 0)
 
Put a filter on the visual for Attribute using Top N and use the ShowColumns measure as the By Value to filter for Top 1.

Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

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.