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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Jeffrey_VC
Helper III
Helper III

Max funtion

Hello Community,


I'm a newbie who is interesting in Power Bi and the working of DAX.

Now I'm trying to get the penultimate record in a colum. Is there a function in DAX what can help me?

 

Please can anyone help me in achiving this measure.

 

Thanks,

Jeffrey

 

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

If you have a unique column in the table, like an ID, then you could do something like

Penultimate value =
VAR maxID =
    MAX ( 'Table'[ID] )
VAR val =
    SELECTCOLUMNS (
        CALCULATETABLE ( TOPN ( 1, 'Table', 'Table'[ID] ), 'Table'[ID] < maxID ),
        "@val", 'Table'[Desired column]
    )
RETURN
    val

View solution in original post

4 REPLIES 4
colacan
Resolver II
Resolver II

Hi, You can filter out the row which has minium value then get the minimum value to find penultimate as below.

colacan_1-1660127947107.png

 

I hope this helps you. 

Thanks

 

 

Hi,

Thank you for your answer.

I have tried:

 

Penultimate =
var minscore = minx(all('Ledigingen uit Middleware'[Datum/tijd]),
        'Ledigingen uit Middleware'[Datum/tijd])
var penul_wo_min = FILTER('Ledigingen uit Middleware',
     'Ledigingen uit Middleware'[Datum/tijd] <> minscore)
return MINX(penul_wo_min,'Ledigingen uit Middleware'[Datum/tijd])
 
 
The result is not the Penultimate but the first in the dataset:
 
Jeffrey_VC_1-1660128890554.pngJeffrey_VC_2-1660128923642.png

And I need:

Jeffrey_VC_3-1660128949992.png

 

 

 

johnt75
Super User
Super User

If you have a unique column in the table, like an ID, then you could do something like

Penultimate value =
VAR maxID =
    MAX ( 'Table'[ID] )
VAR val =
    SELECTCOLUMNS (
        CALCULATETABLE ( TOPN ( 1, 'Table', 'Table'[ID] ), 'Table'[ID] < maxID ),
        "@val", 'Table'[Desired column]
    )
RETURN
    val

Hi Johnt75,

 

Yes that looks like a solution. Thnx!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.