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
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
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 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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