Forum Discussion
Dynamic column in matrix visual
Mariusz Thanks so much . I had gone through your pbix. Can you please what your dax is doing over there.i mean its main functionality?
Hi Anonymous
Sure, please see the explanation commented in the expression.
Measure =
VAR __sum = SUM( 'Table'[Values] ) -- sum of values
VAR __selction = VALUES( 'Columns'[Column1] ) -- list of values selected on the slicer
RETURN
SWITCH(
TRUE(),
/*
ISINSCOPE -
Returns TRUE if the column is in included in the filter context -
t will return TRUE for the column if it is used in the Matrix and all columns with lower granularity
ISINSCOPE( 'Table'[Level3] ) will return true for level3 and level4
NOT
Reverses TRUE to FALSE, so when ISINSCOPE( 'Table'[Level3] ), TRUE will be set on 'Table'[Level1] and 'Table'[Level2]
"Level2" IN __selction
Is the second part of SWITCH logical test that has to be met
"Level2" is a text that is searched for in currently election of Columns'[Column1] / slicer
&&
is other way of saing AND in DAX
Both cryteria, NOT ISINSCOPE( 'Table'[Level3] ) and "Level2" IN __selction -- have to be met for __sum value to be returned
*/
NOT ISINSCOPE( 'Table'[Level2] ) && "Level1" IN __selction, __sum,
NOT ISINSCOPE( 'Table'[Level3] ) && "Level2" IN __selction, __sum,
NOT ISINSCOPE( 'Table'[Level4] ) && "Level3" IN __selction, __sum,
"Level4" IN __selction, __sum
)
let me know if it's clear enough for you.
Mariusz
If this post helps, then please consider Accepting it as the solution.
- Anonymous6 years agoNot applicable
Thanks so much, but if you can see here, pbix attached will occupy space for all columns even though slicer selection is blank or single, whereas requirment doesnt have it.
How about creating custom visual, where users should have ability to add column dynamically to matrix. Is it possible?
- V-lianl-msft6 years agoCommunity Support
Hi Anonymous ,
Based on your description,If there is nothing selected in the slicer, you don’t want to see the value of the matrix.
Here's a blog that can solve your current problems:https://exceleratorbi.com.au/show-or-hide-a-power-bi-visual-based-on-selection/
Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- Anonymous6 years agoNot applicable
Mariusz as per your selection, when i select level 2 , both level1 and level2 are adding to visual. can we do like-only individual column should get added. I mean, when i select level3 only level3 column should get added.
- Anonymous6 years agoNot applicable
Mariusz iam trying to do the way you did in sample pbix, but dynamic nature is not working here.. Do i need to have updated version of powerbi to work with this approach