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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Create a slicer thats groups measure values into ranges/groupings

Hi there,

 

Is it possible to create a slicer that has value ranges/groupings that filter tables/visuals based on if the measures fall into that range/group?

 

I've created the following DAX table as my slicer options;

OptionKey
<100,0001
100,000 - 1,000,0002
1,000,000 - 10,000,0003
>10,000,0004

 

And I have a table of total sales by categories;

CategoryTotal Sales
A90000
B50000
C400000
D600000
E2000000
F7000000
G12000000

 

Total Sales is a measure field that is made up of SUMX(SUMMARIZE(FILTER(sales <> 0), category), price * volume).

 

What I want is to be able to select a slicer option and have it filter the table to the range selected.

 

I've tried using IF, SIWTCH, SELECTEDVALUE and tried a few similar questions/solutions that I have found on here but nothing seems to work.

 

Any help would be great.

 

Cheers

1 ACCEPTED SOLUTION
v-yingjl
Community Support
Community Support

Hi @Anonymous ,

You can create this measure, set its values as 1 and put it in the table visual filter:

Control = 
VAR tab =
    ADDCOLUMNS (
        DISTINCT ( Slicer ),
        "Min",
            SWITCH (
                [Option],
                "<100000", 0,
                "100000 - 1000000", 100000,
                "1000000 - 10000000", 1000000,
                ">10000000", 10000000
            ),
        "Max",
            SWITCH (
                [Option],
                "<100000", 100000,
                "100000 - 1000000", 1000000,
                "1000000 - 10000000", 10000000,
                ">10000000", 10000000000
            )
    )
RETURN
    IF (
        COUNTROWS ( FILTER ( tab, [Total Sales] >= [Min] && [Total Sales] < [Max] ) ) > 0,
        1,
        0
    )

table slicer.png

Attached a sample file in the below, hopes to help you.

 

Best Regards,
Yingjie Li

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

View solution in original post

4 REPLIES 4
v-yingjl
Community Support
Community Support

Hi @Anonymous ,

You can create this measure, set its values as 1 and put it in the table visual filter:

Control = 
VAR tab =
    ADDCOLUMNS (
        DISTINCT ( Slicer ),
        "Min",
            SWITCH (
                [Option],
                "<100000", 0,
                "100000 - 1000000", 100000,
                "1000000 - 10000000", 1000000,
                ">10000000", 10000000
            ),
        "Max",
            SWITCH (
                [Option],
                "<100000", 100000,
                "100000 - 1000000", 1000000,
                "1000000 - 10000000", 10000000,
                ">10000000", 10000000000
            )
    )
RETURN
    IF (
        COUNTROWS ( FILTER ( tab, [Total Sales] >= [Min] && [Total Sales] < [Max] ) ) > 0,
        1,
        0
    )

table slicer.png

Attached a sample file in the below, hopes to help you.

 

Best Regards,
Yingjie Li

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

Greg_Deckler
Super User
Super User

@Anonymous - You could accomplish this with a disconnected table for your slicer. Basically the core idea is to switch how you perform a calculation based upon a slicer selection. Disconnected Table Trick as this article demonstrates: https://community.powerbi.com/t5/Community-Blog/Solving-Attendance-with-the-Disconnected-Table-Trick/ba-p/279563


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Thanks both, I've looked over all the pages and nothing has seemed to work as I want it to. The disconnected tables has been the closest but I have more than 2 values, and when I have been able to kinda of make it work, it only works when 1 value is selected for slicing. If I want 2 options then it doesn't work.


Any other thoughts?

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.