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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Performing calculation only on last 3 values in column (DAX)

Hi all,
I hope someone can help me by suggesting DAX formula for this scenario. I have this column in Excel that I need to replicate in PowerBI

dsBuffer.bmp.png

Any idea how this can be achieved?Thanks in advance for your help.

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , You need some kind of index on the tabled, based that we can get max index and do the operation

Power Query- Index Column: https://youtu.be/NS4esnCDqVw

 

But across to means you have sum all column (DAX example)

new column =

var _max(Table[Index])

Var _secondLast = sumc(filter(Table, Table[index] = _max -1 ), [Col1]+[Col2]+[col3])

Var _Last = sumc(filter(Table, Table[index] = _max ), [col3])

Var _ThirdLast = sumc(filter(Table, Table[index] = _max ), [col3])

return

_ThirdLast + _secondLast  -_Last 

 

 

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

@Anonymous , You need some kind of index on the tabled, based that we can get max index and do the operation

Power Query- Index Column: https://youtu.be/NS4esnCDqVw

 

But across to means you have sum all column (DAX example)

new column =

var _max(Table[Index])

Var _secondLast = sumc(filter(Table, Table[index] = _max -1 ), [Col1]+[Col2]+[col3])

Var _Last = sumc(filter(Table, Table[index] = _max ), [col3])

Var _ThirdLast = sumc(filter(Table, Table[index] = _max ), [col3])

return

_ThirdLast + _secondLast  -_Last 

 

 

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
Anonymous
Not applicable

I was able to figure it out using your formula,thank you a lot!🤗

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.