Tim Armstrong
Tim Armstrong

Reputation: 19

dynamic matrix visual with the 'rows' input fed by slicer selection (power bi)

I am trying to come up with a way to have a matrix visual dynamically change based on the selection of a slicer. The slicer would hold the fields that can be used as the 'rows' selection in the matrix visual. When the selected item in the slicer changes, that automatically updates the matrix output to aggregate the data across the new 'rows'. Currently have have three different pages that each use a static 'rows' selection, but hoping there is a way to merge them all into a single visual / page.

I have tried using the selected value from the slicer as a VAR in a measure with a SWITCH statement, but Power BI did not like that. I also tried a calculated table.

SelectedRows = VAR SelectedField = SELECTEDVALUE('MatrixRowFieldList'[FieldName]) RETURN SWITCH( SelectedField, "betaClass", VALUES('All_Fool__Portfolio_Latest'[betaClass]), "mktCapClass", VALUES('All_Fool__Portfolio_Latest'[mktCapClass]), "Sector", VALUES('All_Fool__Portfolio_Latest'[Sector]), "industry", VALUES('All_Fool__Portfolio_Latest'[industry]), "investStyle", VALUES('StyleThesisConviction'[investStyle]), BLANK() ) error message i get: The expression specified in the query is not a valid table expression.

Any ideas on how to get this to work? Anyone done something similar in a different way that they got to work? Thanks in advance.

Upvotes: 1

Views: 1165

Answers (1)

ttruhcheva
ttruhcheva

Reputation: 424

First thing that comes to mind is using a parameter.

Go to Modeling -> New Parameter -> Fields.

Drag the fields you want (basically the fields which values you want to use). The 'Add slicer to this page' should be checked.

This will create a table 'Parameter', and create a slicer on your page automatically. Make this slicer single select. Add the Parameter column from Parameter table in your matrix rows.

Now whatever you select from that slicer will update the values in your matrix.

In this examples I used fields Country and Continent. Selecting Country will give all the countries I have in my dataset. Same goes for Continent.

Country selection updates Rows to countries:

enter image description here

Continent returns all my continents:

enter image description here

I hope I didn't misunderstand and this is what you tried to achieve!

Upvotes: 1

Related Questions