cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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

Accepted Solutions
Highlighted
Super User IX
Super User IX

Re: Second Last Date Total

@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))



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
My Recent Blog -Week is not so Weak Connect on Linkedin

Proud to be a Super User!

View solution in original post

4 REPLIES 4
Highlighted
Community Champion
Community Champion

Re: Second Last Date Total

Highlighted
Super User IX
Super User IX

Re: Second Last Date Total

@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))



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
My Recent Blog -Week is not so Weak Connect on Linkedin

Proud to be a Super User!

View solution in original post

Highlighted
Resolver I
Resolver I

Re: Second Last Date Total

Hi @amitchandak 

 

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

 

Thanks,

Boycie92

Highlighted
Super User IX
Super User IX

Re: Second Last Date Total

@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])



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
My Recent Blog -Week is not so Weak Connect on Linkedin

Proud to be a Super User!

Helpful resources

Announcements
Meet the 2020 Season 2 Power BI Super Users!

Meet the 2020 Season 2 Power BI Super Users!

Find out who's part of the program this season, and welcome the new Super Users.

August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

July 2020 Community Highlights

July 2020 Community Highlights

Learn about the exciting things that happened in July.

Featured Data Story of The Month

Featured Data Story of The Month

All Data Stories Gallery contributions are reviewed for each month. We select a contribution and feature the community member the following month.

Power BI Dev Camp - Developing with .NET Core

Power BI Dev Camp - Developing with .NET Core

Learn how to develop custom web applications for Power BI using .NET Core 3.1 and .NET 5.

Top Solution Authors
Top Kudoed Authors