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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
TeJai
Frequent Visitor

Last day of sale before a specific date

Hey,

 

I am struggling writing a specific formula for finding the last day of sale before i specific date - and not just the last sales date, as i wish to track "idle" inventory development over time.

 

I have two tables, one with transactions and one with end of month inventory value. I need to write a new column in the financial stock value tabel which specifies the latest day of sale for a product prior to the end of month inventory date (date column in financial stock value tabel).

 

The dates should be extracted from the transaction tabel, date column (for sales entries), and written in the financial stock value tabel, last sale day column. Color coding shows expected output. 

 

Excel tables attached below as well. 

 

Any help is appreciated as this challenge is beyond my DAX knowledge. 

 

TeJai_0-1707576277121.png

 

 

 

Transaction table  
ProductDateTypevalue
A14-05-2023Sales2
A16-05-2023Purchase-2
A27-06-2023Sales2
B16-05-2023Sales1
B16-06-2023Sales1
B27-07-2023Sales1
C14-05-2023Purchase-3
C16-05-2023Sales3
C27-06-2023Sales3

 

Financial Stock value tabel  
Product DateStock valueLast sale dayDays since last sale
A31-05-202310014-05-202317
B30-06-202312027-06-20233
C31-07-20239027-06-202334
A31-05-202310016-05-202315
B30-06-202312016-06-202314
C31-07-20239027-07-20234
A31-05-202310016-05-202315
B30-06-202312027-06-20233
C31-07-20239027-06-202334
1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

Write this calculated column formula

Last sale date = CALCULATE(MAX('Transaction'[Date]),FILTER('Transaction','Transaction'[Product]=EARLIER('Financial stock value'[Product ])&&'Transaction'[Type]="Sales"&&'Transaction'[Date]<=EARLIER('Financial stock value'[Date])))

Hope this helps.

Ashish_Mathur_0-1707611269292.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

Write this calculated column formula

Last sale date = CALCULATE(MAX('Transaction'[Date]),FILTER('Transaction','Transaction'[Product]=EARLIER('Financial stock value'[Product ])&&'Transaction'[Type]="Sales"&&'Transaction'[Date]<=EARLIER('Financial stock value'[Date])))

Hope this helps.

Ashish_Mathur_0-1707611269292.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi Ashish_Mathur,

 

Thanks, simple solution working perfectly - and helped me figure out why my approach based on ISONORAFTER wasn't fit for this issue. 

 

Sincerely,

You are welcome.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Fabric Monthly Update - May 2024

Check out the May 2024 Fabric update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.