Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

Slicer based on category header with drop down

Hi!

 

I have data over where people lived in different time periods. The time periods are with some distance apart and most importantly, new time periods will be added in the future to the dataset. 

I want to create some type of tool (preferably a slicer) which will let me select any city for any time period and combine these in different ways such that i can choose "all people who lived in Chicago during TP1 and those who lived in Seattle during TP4" or what ever combination.

 

Right now my data is structured like this (sorry for excel-file but masked because of customer-integrety):

 

Skärmavbild 2021-07-16 kl. 14.55.21.png

When I just drag all the columns into the slicer-tool I get a slicer with the following structure:

Skärmavbild 2021-07-16 kl. 14.57.01.png

Since Power BI wants me to select a combination in a hierarchy way. Would not be the end of the world if I did not have several timeperiods in the future to add on, and could most likely easily be solved with a pivot if it were just 2 time periods.

 

What I would like is a slicer-tool that just gives me the column headers as foldable items, like when one creates real hierarchys with year and months, but that I instead can click on what time-period I would want to look at and which cities from that particular period.

like this:

Skärmavbild 2021-07-16 kl. 15.00.10.png

 

 Thanks in advance for any help and sorry for the masked and perhaps badly explained excel data.

3 REPLIES 3
v-easonf-msft
Community Support
Community Support

Hi,  @Anonymous 

Please try follow steps:

1.Duplicate a new table in PQ
2.Select columns "Period1","Period2","Period3"  of new table and then unpivot columns in the advanced editor as  shown below :

1.png

3.Create a  new measure and apply to viusal filter pane to filter data:

Measure1 = 
VAR flag =
    SWITCH (
        SELECTEDVALUE ( Slicer[Period Time] ),
        "Period1", IF ( SELECTEDVALUE ( 'Table'[Period1] ) = SELECTEDVALUE ( Slicer[City] ), 1, 0 ),
        "Period2", IF ( SELECTEDVALUE ( 'Table'[Period2] ) = SELECTEDVALUE ( Slicer[City] ), 1, 0 ),
        "Period3", IF ( SELECTEDVALUE ( 'Table'[Period3] ) = SELECTEDVALUE ( Slicer[City] ), 1, 0 ),
        0
    )
RETURN
    IF ( ISFILTERED ( Slicer[Period Time] ), flag, 1 )

 

3.png

 

Best Regards,
Community Support Team _ Eason
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

Anonymous
Not applicable

It works like a charm for the slicer itself, but I'm having trouble connecting it to my original dashboard with the other stats from the original table. When ever I get them to operate togheter (read: that something happens when i click in the slider) I get a twice as high count/sum or what not I am displaying.

Hi,  @Anonymous 

Can you share a sample file for further research?

Maybe there was an error when converting the data in pq, or the results need to be averaged.

 

Best Regards,
Community Support Team _ Eason

 

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.