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
ViralPatel212
Resolver I
Resolver I

Creating a measure to ignore filter context

 

Spoiler
Hello team and  @v-yiruan-msft 

I have a ranking measure called Dealer Ranking 3 and this measure identifies where the dealer "Barclays" is positioned and displays it.

However when i have a filter with client this measure gets sliced and shows where barclays is positioned for that client (per month) however i would like that measure not to change and jus show the Overall position.
Here is a sample file of the report: Sample file 
ViralPatel212_1-1713538987668.png

Here is the measure for Dealer ranking number 2 test:

Dealer Ranking Number 2 test = 
var _rank =  IF( [Ranking Size (Vol)] = blank(), BLANK(), RANKX(ALL('Dealer Ranking'[test 2],'Dealer Ranking'[test]),[Ranking Size (Vol)],,DESC,Dense))
VAR _tab =
    FILTER (
        ADDCOLUMNS (
            ALLSELECTED( 'Dealer Ranking'[test],'Dealer Ranking'[test 2] ),
            "@rank", [Dealer Ranking 3]
        ),
        [test 2] = "Barclays"
    )
VAR _rankbarclays =
    CALCULATE( MAXX ( _tab, [@rank] ),REMOVEFILTERS('Dealer Ranking'[Glimpse_buy_side]))


RETURN

_rankbarclays

Other measures used:

Ranking Size (Vol) = 

VAR _volumeall =
    CALCULATE(
        [Ranking Size],
        FILTER(
            'Dealer Ranking',
            'Dealer Ranking'[Type] = "Vol. (MM)"
        )
    )

VAR _volumeeur =
    CALCULATE(
        [Ranking Size (EUR)],
        FILTER(
            'Dealer Ranking',
            'Dealer Ranking'[Type] = "Vol. (MM)"
        )
    )

RETURN
    IF(
        ISFILTERED('Dealer Ranking'[Currency]),
        _volumeall,
        _volumeeur
    )


Dealer Ranking 3 = IF( [Ranking Size (Vol)] = blank(), BLANK(), RANKX(ALL('Dealer Ranking'[test 2],'Dealer Ranking'[test]),[Ranking Size (Vol)],,DESC,Dense))

 

 

1 ACCEPTED SOLUTION

@sevenhills @Greg_Deckler 

 

I was able to resolve it! 

VAR _rankbarclays =
    CALCULATE (
        MAXX (
            FILTER (
                ADDCOLUMNS (
                    ALL('Dealer Ranking'[Counter Party], 'Dealer Ranking'[Counter Party Blanks]),  // Ignore all slicers/filters on Counter Party
                    "@rank", [Dealer Ranking Number 2 test]
                ),
                [Counter Party] = "Barclays" 
            ),
            [@rank]
        ),
        REMOVEFILTERS('Dealer Ranking'[Glimpse_buy_side])  // Explicitly removing filters on Glimpse_buy_side
    )

RETURN
    _rankbarclays

View solution in original post

12 REPLIES 12
ViralPatel212
Resolver I
Resolver I

@v-yiruan-msft 

 

any chance if you could solve my issue? 

Here is a sample file of the report: Sample file 

 

 

 

sevenhills
Super User
Super User

ALLSELECTED also can be used if you want to apply selected filter contexts.

https://radacad.com/power-bi-dax-all-vs-allselected

 

Your post need to be updated with sample data, and expected output. Hard to understand from code. 

 

 

 

 

Hello @sevenhills i have added a link in the original post where I have share the sample file. 

https://www.dropbox.com/scl/fo/8lbwxkv8mmkgs0albydtv/AIdE_uDnCJhDIChvExvVWuY?rlkey=kzhzcn961isqwveef...

I am able to see and download your 2 files - excel and pbix.

 

I assume that you want the measure to show the exact values irrespective of client selected for Barclays.

 

first part to get the volume is easy and working! slight modification of your volume metric used in the visual.

 

1. Measure Volume all clients = 
IF ( IsBlank([Client size Volume]), BLANK(),  
  CALCULATE( [Client size Volume], 'Dealer Ranking'[Counter Party] = "Barclays", REMOVEFILTERS('Dealer Ranking'[Glimpse_buy_side]))
)

 

When it comes to ranking, for some reason it is not working!

 

 

@sevenhills @Greg_Deckler 

 

I was able to resolve it! 

VAR _rankbarclays =
    CALCULATE (
        MAXX (
            FILTER (
                ADDCOLUMNS (
                    ALL('Dealer Ranking'[Counter Party], 'Dealer Ranking'[Counter Party Blanks]),  // Ignore all slicers/filters on Counter Party
                    "@rank", [Dealer Ranking Number 2 test]
                ),
                [Counter Party] = "Barclays" 
            ),
            [@rank]
        ),
        REMOVEFILTERS('Dealer Ranking'[Glimpse_buy_side])  // Explicitly removing filters on Glimpse_buy_side
    )

RETURN
    _rankbarclays

Glad to hear that it is resolved. 

hi @sevenhills 

 

i dont know why, i am stuck in the same situation as well.

 

ViralPatel212
Resolver I
Resolver I

hi @Greg_Deckler 

 

I have used the ALL function but it seem to not work

 

Dealer Ranking Number 2 test = 
var _rank =  IF( [Ranking Size (Vol)] = blank(), BLANK(), RANKX(ALL('Dealer Ranking'[test 2],'Dealer Ranking'[test]),[Ranking Size (Vol)],,DESC,Dense))
VAR _tab =
    FILTER (
        ADDCOLUMNS (
            ALLSELECTED( 'Dealer Ranking'[test],'Dealer Ranking'[test 2] ),
            "@rank", [Dealer Ranking 3]
        ),
        [test 2] = "Barclays"
    )
VAR _rankbarclays =
    CALCULATE( MAXX ( _tab, [@rank] ),REMOVEFILTERS('Dealer Ranking'[Glimpse_buy_side]))


RETURN

Calculate (_rankbarclays, ALL('Dealer Ranking'))

 

@ViralPatel212 In _tab you are using ALLSELECTED not ALL. It's almost impossible to be specific here without sample data to recreate. 

 

Sorry, having trouble following, can you post sample data as text and expected output?
Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.


@ 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...

Hi @Greg_Deckler 

 

@I have posted a sample file in the original post. But you can download it from here 

https://www.dropbox.com/scl/fo/8lbwxkv8mmkgs0albydtv/AIdE_uDnCJhDIChvExvVWuY?rlkey=kzhzcn961isqwveef...

@ViralPatel212 You can get your 2 base SUM measures to ignore client by doing this:

Ranking Size =
    CALCULATE( SUM('Dealer Ranking'[Size]), REMOVEFILTERS('Dealer Ranking'[Glimpse_buy_side]) )
 
However, try as I might, I can't get the Ranking Size (Vol) measure to remain constant when clicking on clients slicer.

@ 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...
Greg_Deckler
Super User
Super User

@ViralPatel212 Use ALL to override filter context.


@ 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...

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.