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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Boycie92
Resolver I
Resolver I

Second Last Date Total

Hi,

 

I am hoping someone can help I have a very simple table.

 

I would like to be able to create a measure that would provide the figure (total) for the second last date available in my data. So, in this scenario 400. Any ideas?

 

Date                  Total

1/1/2020           100 

2/1/2020           150

3/1/2020           400 

4/1/2020           500 

 

Thanks,

Boycie92

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Boycie92 

measure =
var _max= maxx(allselected(Table),Table[date])
return
calculate(lastnonblankvalue(Table[date],Sum(Table[Total])),Table[Date]<_max)

 

OR


measure =
var _max= maxx(allselected(Table),Table[date])
return
calculate(lastnonblankvalue(Table[date],Sum(Table[Total])),filter(allselected(Table),Table[Date]<_max))

View solution in original post

4 REPLIES 4
amitchandak
Super User
Super User

@Boycie92 

measure =
var _max= maxx(allselected(Table),Table[date])
return
calculate(lastnonblankvalue(Table[date],Sum(Table[Total])),Table[Date]<_max)

 

OR


measure =
var _max= maxx(allselected(Table),Table[date])
return
calculate(lastnonblankvalue(Table[date],Sum(Table[Total])),filter(allselected(Table),Table[Date]<_max))

Hi @amitchandak 

 

That works perfectly thank yo so much. Is there anyway to display the second las date as a seperate messure?

 

Thanks,

Boycie92

@Boycie92 , Create a measure in the same way as the last one and  in that use

max(Table[Date]) in place of Sum(Table[Total])

Fowmy
Super User
Super User

@Boycie92 

Please check this solution, 

https://community.powerbi.com/t5/Desktop/Show-second-last-date-value-in-card/td-p/531093

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors