Forum Discussion

rdurrell's avatar
rdurrell
Frequent Visitor
1 year ago
Solved

Toggle Values visible on Matrix Visual

Hello,   I am having issues trying to toggle what fields are visible in my matrix visual. I cannot share specifics about my data, but will give an example: I have data sales by state by year. In m...
  • DataNinja777's avatar
    1 year ago

    Hi rdurrell ,

     

    You can achieve this by using Field Parameters in Power BI. Instead of just blanking out the values when the user selects "No" for showing %YoY Change, Field Parameters allow you to dynamically control which fields appear in the matrix, effectively removing the column entirely when not selected.

    First, create a Field Parameter by going to the Modeling tab and selecting New Parameter → Fields. Name the parameter something like "Matrix Toggle" and select the fields you want to toggle (e.g., Sales and %YoY Change). Power BI will generate a new table with a DAX expression similar to the following:

    Matrix Toggle = {
        ("Sales", NAMEOF('Sales Table'[Sales]), 0),
        ("%YoY Change", NAMEOF('Sales Table'[%YoY Change]), 1)
    }
    

    This table acts as a toggle, allowing users to select which measures appear in the matrix. Next, remove the existing measures from the Values section of your matrix and instead, add the newly created Matrix Toggle field. The field parameter table also creates a slicer, where users can choose which values to display.

    When the user selects "Sales", only the Sales measure appears in the matrix. If they select both "Sales" and "%YoY Change", both fields appear dynamically. If %YoY Change is not selected, it completely disappears rather than showing a blank column.

    If you want to enhance the user experience, change the slicer to a Single Select dropdown to make it a simple toggle. If you want users to select multiple fields, leave it as a Multi-Select slicer. This approach is far better than using a measure with BLANK() because it fully controls field visibility in the matrix.

     

    Best regards,