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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
whichOne
Frequent Visitor

matrix show columns based on slicer selection

I have a table with multiple columns structure similar to this:

 measure 1measure 2measure 3measure 4
company a    
company b    

 

I am trying to ad a slicer and based on the slicer result, show different segment of the table. For example, if slicer select 1, show measures 1 and 2; if slicer select 2, show measure 3 and 4. 

 

I was able to create a slicer, but stuck at grouping columns using the code below. Error message says it contains multiple columns, cannot be converted to scalar value.

 

DynamicTable =
VAR SelectedValue = SELECTEDVALUE(ParameterTable[Parameter], "None")
RETURN
SWITCH(
SelectedValue,
"Slicer value 1",
SELECTCOLUMNS(
'table',
"measure 1", [measure 1],
"measure 2", [measure 2]
),
"Slicer value 2",
SELECTCOLUMNS(
'table',
"measure 3", [measure 3],
"measure 4", [measure 4]
))

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @whichOne 

Based on your needs, I have created the following table.

vjialongymsft_0-1723099584849.png


vjialongymsft_1-1723099606049.png

 

 


Then you can create a measure by using the following dax:

Dynamic = SWITCH(TRUE(),
SELECTEDVALUE('Parameter (2)'[Parameter]) = 1,CALCULATE(SELECTEDVALUE('Table'[VALUE]),FILTER('Table','Table'[Column1] = 1 || 'Table'[Column1] = 2)),
SELECTEDVALUE('Parameter (2)'[Parameter]) = 2,CALCULATE(SELECTEDVALUE('Table'[VALUE]),FILTER('Table','Table'[Column1] = 3 || 'Table'[Column1] = 4)),
SELECTEDVALUE('Table'[VALUE]) )

 



Put the corresponding fields into the table so that you can make the table display specific columns based on the slicer selection.

vjialongymsft_2-1723099742809.png

 

 

 

Result:

 

vjialongymsft_3-1723099862135.png
vjialongymsft_4-1723099868848.png



 

Best Regards,

Jayleny

 

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

5 REPLIES 5
Anonymous
Not applicable

Hi @whichOne 

Based on your needs, I have created the following table.

vjialongymsft_0-1723099584849.png


vjialongymsft_1-1723099606049.png

 

 


Then you can create a measure by using the following dax:

Dynamic = SWITCH(TRUE(),
SELECTEDVALUE('Parameter (2)'[Parameter]) = 1,CALCULATE(SELECTEDVALUE('Table'[VALUE]),FILTER('Table','Table'[Column1] = 1 || 'Table'[Column1] = 2)),
SELECTEDVALUE('Parameter (2)'[Parameter]) = 2,CALCULATE(SELECTEDVALUE('Table'[VALUE]),FILTER('Table','Table'[Column1] = 3 || 'Table'[Column1] = 4)),
SELECTEDVALUE('Table'[VALUE]) )

 



Put the corresponding fields into the table so that you can make the table display specific columns based on the slicer selection.

vjialongymsft_2-1723099742809.png

 

 

 

Result:

 

vjialongymsft_3-1723099862135.png
vjialongymsft_4-1723099868848.png



 

Best Regards,

Jayleny

 

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

 

 

whichOne
Frequent Visitor

Could you elaborate a bit on how to do that? 

@whichOne Use an Enter Data query and enter data like:

Column1

Measure1

Measure2

Measure3

Measure4

 

Don't connect it to anything (no relationships). Use this in your Columns field well in your matrix and in your slicer. Then use a single measure along the lines of:

Selected Measure =
  VAR __Measure = MAX('Disconnected Table'[Column1])
  VAR __Result =
    SWITCH( __Measure,
      "Measure1", [Measure1],
      "Measure2", [Measure2],
      "Measure3", [Measure2],
      "Measure4
    )
RETURN
  __Result


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Ah ok I see what you mean. The column names might be confusing, they are not actually measures, they are just my table column attributions, I am calling them "measure". Should I make all the columns in the table measure first? I dont think I can just use columns directly like you purposed.

Greg_Deckler
Community Champion
Community Champion

@whichOne Pretty certain that you need to use a disconnected table for your columns and then a single measure that determines what to display based on your 4 measures.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.