The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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
Solved! Go to Solution.
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, You can filter out the row which has minium value then get the minimum value to find penultimate as below.
I hope this helps you.
Thanks
Hi,
Thank you for your answer.
I have tried:
And I need:
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!
User | Count |
---|---|
27 | |
12 | |
8 | |
8 | |
5 |
User | Count |
---|---|
31 | |
15 | |
12 | |
11 | |
7 |