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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

Dynamic filter range

Hello, I need some help please.

 

i have two tables:
City

BiDevOO_0-1698770631962.png


and sales:

BiDevOO_1-1698770642680.png

 



when i select some city. i want to see the the top 3 cities that the sales is +500 then my current filter city,
for example:

BiDevOO_2-1698770707514.png

 

 

if I select Yavne, i Want to see:

Modiin 200
Tel Aviv 500
Rehovot 700
here is my test file:
https://file.io/MaQvddQ8nmUk
can some one help me please? 

Thank you!





1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

I created a sample pbix file(see the attachment), please check if that is what you want.

1. Create another city dimension table(DO NOT create any relationship with other table)

Table = VALUES(City[CityName])

vyiruanmsft_0-1698897306792.png

2. Create a measure as below to judge which city fulfill the conditions

Flag =
VAR _cities =
    ALLSELECTED ( 'Table'[CityName] )
VAR _selcids =
    SELECTEDVALUE ( 'City'[CityID] )
VAR _cids =
    CALCULATETABLE (
        VALUES ( 'City'[CityID] ),
        FILTER ( ALLSELECTED ( 'City' ), 'City'[CityName] IN _cities )
    )
VAR _sales =
    CALCULATE (
        SUM ( 'Sales'[Column1] ),
        FILTER ( ALLSELECTED ( 'Sales' ), 'Sales'[CityID] IN _cids )
    )
VAR _tab =
    SUMMARIZE (
        'Sales',
        'Sales'[CityID],
        "@sales",
            CALCULATE (
                SUM ( 'Sales'[Column1] ),
                FILTER (
                    ALLSELECTED ( 'Sales' ),
                    'Sales'[CityID] = EARLIER ( 'Sales'[CityID] )
                )
            )
    )
RETURN
    IF (
        _selcids
            = MAXX (
                FILTER ( _tab, [@sales] >= _sales && [@sales] <= _sales + 500 ),
                [CityID]
            ),
        1,
        0
    )

3. Create a table visual and apply a visual-level filter with the condition(Flag is 1)

vyiruanmsft_1-1698897393627.png

Best Regards

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

Hi @Anonymous ,

It seems that the shared file has been deleted...

https://file.io/MaQvddQ8nmUk

vyiruanmsft_0-1698897588017.png

Best Regards

Anonymous
Not applicable

Hi @Anonymous ,

I created a sample pbix file(see the attachment), please check if that is what you want.

1. Create another city dimension table(DO NOT create any relationship with other table)

Table = VALUES(City[CityName])

vyiruanmsft_0-1698897306792.png

2. Create a measure as below to judge which city fulfill the conditions

Flag =
VAR _cities =
    ALLSELECTED ( 'Table'[CityName] )
VAR _selcids =
    SELECTEDVALUE ( 'City'[CityID] )
VAR _cids =
    CALCULATETABLE (
        VALUES ( 'City'[CityID] ),
        FILTER ( ALLSELECTED ( 'City' ), 'City'[CityName] IN _cities )
    )
VAR _sales =
    CALCULATE (
        SUM ( 'Sales'[Column1] ),
        FILTER ( ALLSELECTED ( 'Sales' ), 'Sales'[CityID] IN _cids )
    )
VAR _tab =
    SUMMARIZE (
        'Sales',
        'Sales'[CityID],
        "@sales",
            CALCULATE (
                SUM ( 'Sales'[Column1] ),
                FILTER (
                    ALLSELECTED ( 'Sales' ),
                    'Sales'[CityID] = EARLIER ( 'Sales'[CityID] )
                )
            )
    )
RETURN
    IF (
        _selcids
            = MAXX (
                FILTER ( _tab, [@sales] >= _sales && [@sales] <= _sales + 500 ),
                [CityID]
            ),
        1,
        0
    )

3. Create a table visual and apply a visual-level filter with the condition(Flag is 1)

vyiruanmsft_1-1698897393627.png

Best Regards

Anonymous
Not applicable

Thank you very much, I really apprciate it.
It works great but if i need to slice the CityName from my origial dimension? I have more visuals in the same dashboard so I need to slice the other visuals as well.

Thanks again!

Anonymous
Not applicable

Hi @Anonymous ,

I'm afraid that it can't be achieved when you apply the CityName from your original dimension table. If you applied that field on the slicer, the visual will only display the data with the selected city not display the others. The possible workaround may be this:

1. Keep the current slicer

2. Create another slicer which applied the field [CityName] of original dimension table to filter the other visuals

3. Important: please cancel the interaction  between the new slicer and the original table visual just as below screenshot.

Change how visuals interact in a report - Power BI | Microsoft Learn

vyiruanmsft_0-1699006461892.png

Best Regards

Anonymous
Not applicable

Ok,Thank you very much!

Anonymous
Not applicable

I mean that the range is between my current sales and my current sales + 500.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.