Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Custom slicer to select and display multiple columns

Hello,

 

I am trying to create a custom slicer based on multiple columns. Here is the data I have currently: 

aabbccdd 2020 A2020 B2020 C2021 A2021 B2021 C2022 A2022 B2022 C
a1b1c1d1Customer 1         
a2b2c2d2Customer 2         
a3b3c3d3Customer 3         

 

I want to create a slicer such that I can select one or multiple specific years. For example, if I select "2020" in the slicer, the output would look like this:

aabbccdd 2020 A2020 B2020 C
a1b1c1d1Customer 1   
a2b2c2d2Customer 2   
a3b3c3d3Customer 3   

 

How can I do this?

 

Really appreciate your help - thanks!

 

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi Anonymous ,

    I updated my pbix file(see the attachment), please find the details in it.

    The below one is my answer of your above questions:

    1. It has been achieved in my updated pbix file.

    2 and 3: I'm sorry those two things can't be accomplished. Regarding your third question, you can add the latest year to the YEAR table to avoid that the latest year's data can't be rendered in table visual. 

    Using unpivot+matrix is the best solution to solve your three problems. (Years are multi-selected, unselected years are not shown in the visual, slicer options are from this table)

    Best Regards

8 Replies

  • Hi Anonymous 

    You need to unpivot all columns but customer so those column names go to the rows and then split or extract the year and category (ABC) from the unpivoted columns. Your data should something like below after the transformation:

    Please see attached pbix for your reference.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thank you for your reply. I actually have more columns in addition to the Customer column that I would like to preserve (see below). Does the aforementioned method also work? I'm worried that it might be too messy.

       

      aabbCustomerddee2020 A2020 B2020 C2021 A2021 B...
      a1b1Customer 1d1e1     
      a2b2Customer 2d2e2     
      a3b3Customer 3d3e3     

       

      Really appreciate your help - thank you!

      • Anonymous's avatar
        Anonymous
        Not applicable

        danextian Thanks for your contribution on this thread.

        Hi Anonymous ,

        danextian has provided the possible solution, here need to make a little adjustment: select the columns which include year info and only unpivot these selected columns in Power Query Editor. Please find the details in the attachment.

        1. Only unpivot the columns which include year info

        = Table.Unpivot(#"Changed Type", {"2020 A", "2020 B", "2020 C", "2021 A", "2021 B", "2021 C"}, "Attribute", "Value")

        2. Create a Text filter and matrix visual with below settings 

        Best Regards