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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
shoeb1359
Helper III
Helper III

Find out the second last progress Id with respect to each User id

Hi,

Need your help !!

For every user_id there are multiple Progress_id. I am trying to find out the second last progress_id with respect to each user_id. I want to create a column as Result which will have the second last progress_id . Screenshot below.

Issue.PNG



1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@shoeb1359 , Try a new measure like

 

Measure =
VAR __id = MAX ('Table'[user_ID] )
VAR __date = CALCULATE ( MAX('Table'[progress id] ), ALLSELECTED ('Table' ), 'Table'[user_ID] = __id )
CALCULATE ( MAX ('Table'[progress id] ), VALUES ('Table'[user_ID] ),'Table'[user_ID] = __id,'Table'[progress id] < __date )

 

 

new column =
var _max = maxx(filter(Table, [user_ID] =earlier([user_ID]) ),[progress id])
return
maxx(filter(Table, [user_ID] =earlier([user_ID]) && [progress id] <_max ),[progress id])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@shoeb1359 , Try a new measure like

 

Measure =
VAR __id = MAX ('Table'[user_ID] )
VAR __date = CALCULATE ( MAX('Table'[progress id] ), ALLSELECTED ('Table' ), 'Table'[user_ID] = __id )
CALCULATE ( MAX ('Table'[progress id] ), VALUES ('Table'[user_ID] ),'Table'[user_ID] = __id,'Table'[progress id] < __date )

 

 

new column =
var _max = maxx(filter(Table, [user_ID] =earlier([user_ID]) ),[progress id])
return
maxx(filter(Table, [user_ID] =earlier([user_ID]) && [progress id] <_max ),[progress id])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thanks, Amit for the Solution. Surely I will Implement this.
Although one solution I figured out earlier, please suggest this approach feasible in terms of performance.

Rank =
RANKX (
FILTER (
table,
table[User_ID] = EARLIER ( table[User_ID] )
),
table[Progress ID],
,
ASC
)

 

Another column : 
Progress id_2=
CALCULATE (
MAXX(
table,
CALCULATE(
SUM(table[Progress ID]),
FILTER(
table,
table[User_ID] = EARLIER (table[User_ID] )
&& table[Rank]
=EARLIER ( table[Rank] )-1
),
ALLEXCEPT(table,table[User_ID])
)
),
ALLEXCEPT(table,table[User_ID])
)


Third column: 
Previous profile = IF(table[Progress id_2]=BLANK(),table[Teacher_ID],table[Progress id_2])

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.