Forum Discussion

hallmarke14's avatar
hallmarke14
Frequent Visitor
1 year ago

Power BI - Dynamic View Options - Matrix

I have been asked to make a matrix dynamic in a sense that you could check and uncheck a box to only have certain columns show or hide.  Attached is a mockup:

 

Any ideas or suggestions will be greatly appreciated!

7 Replies

    • hallmarke14's avatar
      hallmarke14
      Frequent Visitor

      Hi, Vicky.  Just wanted to thank you for the tip and provide an update.  We use Analysis Services, so we have a Live Connection for this particular report.  I understand that there is a limitation on that, so I found an alternative solution, which was to create a table in SSAS of the names of the columns and create the following measure:

       

      SelectedMeasureShow =
      SWITCH(
          SELECTEDVALUE(ColumnSelector[Column]),
          "Units TY", FORMAT([UnitsTYShow], "#,##0"),
          "Units SDLY", FORMAT([UnitsSDLYShow], "#,##0"),
          "% CHG Units", FORMAT([%CHGUnitsShow], "0.0%"),
          "Sales TY", FORMAT([SalesTYShow], "$#,##0"),
          "Sales SDLY", FORMAT([SalesSDLYShow], "$#,##0"),
          "% CHG Sales", FORMAT([%CHGSalesShow], "0.0%")
      )
       
      I created a slicer that uses the column table and it works very nicely, but since the matrix uses one measure, I am not able to implement conditional formating for the % measures (red for negative numbers, and green for postive) without it affecting all of the results.  I would like to be able to have the matrix to accept multiple selections, but it doesn't like it when I select more than one measure.

      If anyone has any ideas or a tricks to allowing conditional formatting when there is only one measure or a way to be able to select multiple selections to expand the matrix beyond the initial 6 columns, that would be greatly appreciated!
      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi hallmarke14 ,

        I create a table as you mentioned.

        Then I think you can create some measures and here are the DAX codes.

        UnitsTYShow = SUM(SalesData[UnitsTY])
        UnitsSDLYShow = SUM(SalesData[UnitsSDLY])
        %CHGUnitsShow = DIVIDE([UnitsTYShow] - [UnitsSDLYShow], [UnitsSDLYShow], 0)
        SalesTYShow = SUM(SalesData[SalesTY])
        SalesSDLYShow = SUM(SalesData[SalesSDLY])
        %CHGSalesShow = DIVIDE([SalesTYShow] - [SalesSDLYShow], [SalesSDLYShow], 0)

        You can also create colors on them.

        %CHGUnitsColor = IF([%CHGUnitsShow] < 0, "Red", "Green")
        %CHGSalesColor = IF([%CHGSalesShow] < 0, "Red", "Green")

        Then I create a new table and also create a measure.

        ColumnSelector = 
        DATATABLE(
            "Column", STRING,
            {
                {"Units TY"},
                {"Units SDLY"},
                {"% CHG Units"},
                {"Sales TY"},
                {"Sales SDLY"},
                {"% CHG Sales"}
            }
        )

        SelectedMeasureShow = 
        SWITCH(
            SELECTEDVALUE(ColumnSelector[Column]),
            "Units TY", FORMAT([UnitsTYShow], "#,##0"),
            "Units SDLY", FORMAT([UnitsSDLYShow], "#,##0"),
            "% CHG Units", FORMAT([%CHGUnitsShow], "0.0%"),
            "Sales TY", FORMAT([SalesTYShow], "$#,##0"),
            "Sales SDLY", FORMAT([SalesSDLYShow], "$#,##0"),
            "% CHG Sales", FORMAT([%CHGUnitsShow], "0.0%")
        )

         

         

         

        Best Regards

        Yilong Zhou

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