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

Top Solution Authors