cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
iamprajot
Responsive Resident
Responsive Resident

This DAX formula is not working.

Result =
VAR SecondLast = CALCULATE(MAX(Data[Units]),FILTER(ALL(Data[Units]),Data[Units]<MAX(Data[Units])))
RETURN
CALCULATE(VALUES(Data[Units]),FILTER(ALL(Data),Data[Units]=SecondLast))

 

In SecondLast I am trying to get the second Max Unit available

& finally trying to get the second Max Unit available for whatever the selection I have put in from other columns e.g. Items, Dates etc

But seems like there is no result (blank) in this SecondLast variable and hence no result at all.

3 REPLIES 3
v-chuncz-msft
Community Support
Community Support

@iamprajot,

 

Things are harder when you have nested CALCULATE statements. You may try using RANKX Function instead.

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks but what I am curious about is that it is working without the columnname and not with it.

ALL(Data[Units]) - not working

ALL(Data[Units]) - removing column name worked

iamprajot
Responsive Resident
Responsive Resident

Removing Column Name and keeping the Table Name did the thing, but WHY and HOW ? It doesn't matter if I keep whole Table or a single Column.

Result =
VAR SecondLast = CALCULATE(MAX(Data[Units]),FILTER(ALL(Data[Units]),Data[Units]<MAX(Data[Units])))
RETURN
CALCULATE(VALUES(Data[Units]),FILTER(ALL(Data),Data[Units]=SecondLast))

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors