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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
dancarr22
Helper V
Helper V

Using ALLEXCEPT to get value outside of current filters/context

Hello,

 

I am encountering difficulties using ALLEXCEPT.   Have also tried ALL and ALLSELECTED but none seem to work.

We have the following dataset:

SecurityDateAmount
XYZ12/31/2020468
XYZ3/31/2021657
XYZ6/30/2021389

 

The date column of this field joins to the date field in our date table - not sure if that impacts this.

What we need to do is get the MAX(Date) which is LESS THAN the given filters/context dates.

So, if filtered (and context) date range is 1/1/2021-3/31/2022 - we need to return date 12/31/2020 - which is 'outside' of the filtered date dataset.  So, need to remove any filters related to that date column.  
Currently have this:

StartingValueDate = VAR startDate = MIN(SecurityAmounts[Date])
RETURN CALCULATE(MAX(SecurityAmounts[Date]),   ALLSELECTED(SecurityAmounts[Date]), SecurityAmounts[Date] < startDate)

ALLSELECTED comes the closest but doesn't work when multiple securities are selected.  Basically, just need to remove the filter on the Date field for this measure.  Tried REMOVEFILTERS too but that did not work.  Appreciate any assistance which can be provided.

Thanks,
Dan
1 ACCEPTED SOLUTION
FreemanZ
Super User
Super User

A measure with the code below shall work:

 

StartingValueDate =
VAR MinDate = MIN (SecurityAmounts[Date])
RETURN
    MAXX (
        FILTER(ALL(SecurityAmounts[Date]), SecurityAmounts[Date] < MinDate),
        SecurityAmounts[Date]
)
 
FreemanZ_0-1668215245393.png

 

View solution in original post

2 REPLIES 2
CNENFRNL
Community Champion
Community Champion

Simple enough

CNENFRNL_0-1668236966332.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

FreemanZ
Super User
Super User

A measure with the code below shall work:

 

StartingValueDate =
VAR MinDate = MIN (SecurityAmounts[Date])
RETURN
    MAXX (
        FILTER(ALL(SecurityAmounts[Date]), SecurityAmounts[Date] < MinDate),
        SecurityAmounts[Date]
)
 
FreemanZ_0-1668215245393.png

 

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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