Forum Discussion
How could implement selecting columns which shows in table dynamically?
Hi,
I have requirment as follow:
we have a table :
| A1 | A2 | A3 | M1 | M2 | M3 |
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/false#M288749
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
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)RETURNIF(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.
15 Replies
- amitchandakSuper User
- AnonymousNot 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
- v-lionel-msftCommunity Support
Hi Anonymous ,
What problem have you met? You just need to do like this.
1. Unpivot the columns.
2. Add the columns to the matrix.
Best regards,
Lionel ChenIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- AllisonKennedyCommunity ChampionUse 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
- AnonymousNot 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 :and I created measure as follow:
ShowColumns =Var SlicerSelection = VALUES(Slicer[Column1])Var AlwaysShow = {("A1"); ("A2"); ("A3")}Var ShowValues = UNION(SlicerSelection; AlwaysShow)RETURNIF(SELECTEDVALUE('Table'[Attribute]) IN ShowValues; 1; 0)do you have any Idea?I appreciate your help on this matter.Regards,Matin- AllisonKennedyCommunity ChampionHow 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.
- AnonymousNot applicable