Forum Discussion

prad001's avatar
prad001
Frequent Visitor
1 year ago
Solved

Using Column Names as Slicer Option

I hope you're doing well.

I have a question regarding slicer in Power Bi. Example:  I'm working with a table named "cars" that contains the following columns: Make, model. year and mielage. 

I would like to set up a slicer where the options are the column names themselves-for example, "make" and "model"-instead of values within those columns. When a user selects one or more of these column names in the slicer, the visual below should display all the records where the selected column(s) contain the string value "missing".
Is there a way to achieve this setup in power BI? Any guidance or workaround would be greatly appreciated.

4 Replies

  • Create a Disconnected Table for Column Selection

    In Power BI, go to Modeling > New Table and create this:

    MissingColumns =

    DATATABLE(

        "ColumnName", STRING,

        {

            { "Make" },

            { "Model" },

            { "Year" },

            { "Mileage" }

        }

    )

    This will be the source for your slicer.

    Create a DAX Measure to Check If a Row Has "Missing" in a Selected Column

    Add this measure to your model:

    ShowRow =

    VAR SelectedColumns = VALUES(MissingColumns[ColumnName])

    VAR IsMakeMissing = "Make" IN SelectedColumns && SELECTEDVALUE(Cars[Make]) = "missing"

    VAR IsModelMissing = "Model" IN SelectedColumns && SELECTEDVALUE(Cars[Model]) = "missing"

    VAR IsYearMissing = "Year" IN SelectedColumns && SELECTEDVALUE(Cars[Year]) = "missing"

    VAR IsMileageMissing = "Mileage" IN SelectedColumns && SELECTEDVALUE(Cars[Mileage]) = "missing"

    RETURN

    IF(IsMakeMissing || IsModelMissing || IsYearMissing || IsMileageMissing, 1, 0)

    1. Apply a Visual-Level Filter on the Table Visual

    Now add a table visual to show your Cars data.

    Then:

    • Drag the ShowRow measure into the visual’s Filters pane
    • Set filter to ShowRow = 1

    Now You Can:

    • Use a slicer on MissingColumns[ColumnName]
    • Select one or more column names (like "Model" and "Mileage")
    • The table will dynamically show rows where either column has the value "missing"

     

  • Hi prad001  ,

     

    As per your post description, I used DAX expression to handle the scenario.
    Please find the attached pbix file for your reference.

    Using Column Names as Slicer Option.pbix

    Please let me know if you have further questions.

    If this reply helped solve your problem, please consider clicking "Accept as Solution" so others can benefit too. And if you found it useful, a quick "Kudos" is always appreciated, thanks! 

     

    Best Regards, 

    Maruthi 

    LinkedIn - http://www.linkedin.com/in/maruthi-siva-prasad/ 

    X            -  Maruthi Siva Prasad - (@MaruthiSP) / X

  • Hi  prad001 ,

     

    As per your post description, I used DAX expression to handle the scenario.
    Please find the attached pbix file for your reference.

    Using Column Names as Slicer Option.pbix

    Please let me know if you have further questions.

    If this reply helped solve your problem, please consider clicking "Accept as Solution" so others can benefit too. And if you found it useful, a quick "Kudos" is always appreciated, thanks! 

     

    Best Regards, 

    Maruthi 

    LinkedIn - http://www.linkedin.com/in/maruthi-siva-prasad/ 

    X            -  Maruthi Siva Prasad - (@MaruthiSP) / X

  • v-veshwara-msft's avatar
    v-veshwara-msft
    Community Support

    Hi prad001 ,

    Thank you for engaging with the Microsoft Fabric Community.

    Many thanks to maruthisp  and Shravan133  for their prompt and helpful responses to this query.

     

    I’ve reviewed and tested the .pbix file shared by maruthisp , and I can confirm that the provided solutions are accurate and meet the requirements outlined in your query. Please take a moment to review the responses, and feel free to share any feedback or let us know if you need further assistance.

     

    If the replies have resolved your issue, kindly consider marking the appropriate response as the Accepted Solution and giving kudos to help others with similar questions.

     

    Thank you.