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
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
Super User
Super User

@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
Super User
Super User

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