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
FilipVDR
Helper I
Helper I

Dax Measure which ignores one filter is not working

To calculate the cars that went out of service (VoertuigDatumUitDienst) in the last year i'm creating this measure.
I want to ignore the CarStatus slicer (VoertuigStatusCode). Though it keeps changing my measure when I filter on VoertuigStatusCode. Any idea's?
 
AantalAutoUitDienstAfgelopenJaar =
CALCULATE(
    DISTINCTCOUNT('d_voertuig'[D_Voertuig_BID]),
    ALLEXCEPT('d_voertuig', 'd_voertuig'[VoertuigStatusCode]),
    FILTER(
        'd_voertuig',
        'd_voertuig'[VoertuigDatumUitDienst] >= DATE(YEAR(TODAY())-1,1,1) &&
        'd_voertuig'[VoertuigDatumUitDienst] <= DATE(YEAR(TODAY())-1,12,31)
    )
)
1 ACCEPTED SOLUTION
FilipVDR
Helper I
Helper I

I found the solution was easier than I thought:

AantalAutoUitDienstAfgelopenJaar =
CALCULATE(
    DISTINCTCOUNT('d_voertuig'[D_Voertuig_BID]),
    REMOVEFILTERS(d_voertuig[VoertuigStatusCode]),
    year(d_voertuig[VoertuigDatumUitDienst]) = year(today())-1
)

View solution in original post

5 REPLIES 5
FilipVDR
Helper I
Helper I

I found the solution was easier than I thought:

AantalAutoUitDienstAfgelopenJaar =
CALCULATE(
    DISTINCTCOUNT('d_voertuig'[D_Voertuig_BID]),
    REMOVEFILTERS(d_voertuig[VoertuigStatusCode]),
    year(d_voertuig[VoertuigDatumUitDienst]) = year(today())-1
)
talespin
Solution Sage
Solution Sage

hi @FilipVDR 

 

If possible please share pbix file with mock data.

talespin
Solution Sage
Solution Sage

hi @FilipVDR 

 

Instead of ALLEXCEPT('d_voertuig''d_voertuig'[VoertuigStatusCode])

use

REMOVEFILTERS('d_voertuig'[VoertuigStatusCode])

When I change to removefilters, same behavior. When i click on the slicer of "voertuigstatuscode" the measure keeps changing.
 
AantalAutoUitDienstAfgelopenJaar =
CALCULATE(
    DISTINCTCOUNT('d_voertuig'[D_Voertuig_BID]),
    REMOVEFILTERS('d_voertuig'[VoertuigStatusCode]),
    FILTER(
        'd_voertuig',
        'd_voertuig'[VoertuigDatumUitDienst] >= DATE(YEAR(TODAY())-1,1,1) &&
        'd_voertuig'[VoertuigDatumUitDienst] <= DATE(YEAR(TODAY())-1,12,31)
    )
)

Hi @FilipVDR 
 
You also need to remove filter on table.
 
I have used ALL(Tablename), please do not use only table name, instead use
ALL(Column or column names)
Example ALL('d_voertuig'[D_Voertuig_BID], 'd_voertuig'[VoertuigDatumUitDienst])
ALLSELECTED if you want another slicer to impact this measure.
 
CALCULATE(
    DISTINCTCOUNT('d_voertuig'[D_Voertuig_BID]),
    REMOVEFILTERS('d_voertuig'[VoertuigStatusCode]),
    FILTER(
        ALL('d_voertuig'),
        'd_voertuig'[VoertuigDatumUitDienst] >= DATE(YEAR(TODAY())-1,1,1) &&
        'd_voertuig'[VoertuigDatumUitDienst] <= DATE(YEAR(TODAY())-1,12,31)
    )
)

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.