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
Mike99Schmidt
Frequent Visitor

Get previous date where values in other columns match

I have a union table that was created from two summary tables from separate queries.

 

The columns that I currently have is Site, Dept, Date. I need to create an additonal column that calculates the previous date in the date column where the site and dept match so we can analyze the shrink per day for the department. Below is a sample of what the table will look like once I can figure out how to calculate the previous date column. Thanks for any assistance on this!!

 

SiteDeptDateO/sLast DateDate Diff
163Packaged Beverage10/21/201969/8/201943
165OTP10/20/201976/8/2019134
166Snacks10/20/201935/4/2019169
163Packaged Beverage9/8/201944/1/2019160
165OTP6/8/201913/1/201999
166Snacks5/4/201922/1/201992
1 ACCEPTED SOLUTION
Nathaniel_C
Community Champion
Community Champion

@Mike99Schmidt ,

Try this:
Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos are nice too.
Nathaniel

 

 

Last date calc = 
var _cDate ='Table'[Date]

var _calc = CALCULATE(MAX('Table'[Date]),FILTER(ALLEXCEPT('Table','Table'[Site],'Table'[Dept]),'Table'[Date]<_cDate))

return _calc





dateprevious 10 22 2019.PNG

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

4 REPLIES 4
Nathaniel_C
Community Champion
Community Champion

@Mike99Schmidt ,

Try this:
Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos are nice too.
Nathaniel

 

 

Last date calc = 
var _cDate ='Table'[Date]

var _calc = CALCULATE(MAX('Table'[Date]),FILTER(ALLEXCEPT('Table','Table'[Site],'Table'[Dept]),'Table'[Date]<_cDate))

return _calc





dateprevious 10 22 2019.PNG

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




That worked perfectly thanks!!!!

 

@Nathaniel_C 

 

You are welcome!

Nathaniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




PBIX MY FILE 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




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.