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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

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
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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