Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
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.
Transaction table | |||
Product | Date | Type | value |
A | 14-05-2023 | Sales | 2 |
A | 16-05-2023 | Purchase | -2 |
A | 27-06-2023 | Sales | 2 |
B | 16-05-2023 | Sales | 1 |
B | 16-06-2023 | Sales | 1 |
B | 27-07-2023 | Sales | 1 |
C | 14-05-2023 | Purchase | -3 |
C | 16-05-2023 | Sales | 3 |
C | 27-06-2023 | Sales | 3 |
Financial Stock value tabel | ||||
Product | Date | Stock value | Last sale day | Days since last sale |
A | 31-05-2023 | 100 | 14-05-2023 | 17 |
B | 30-06-2023 | 120 | 27-06-2023 | 3 |
C | 31-07-2023 | 90 | 27-06-2023 | 34 |
A | 31-05-2023 | 100 | 16-05-2023 | 15 |
B | 30-06-2023 | 120 | 16-06-2023 | 14 |
C | 31-07-2023 | 90 | 27-07-2023 | 4 |
A | 31-05-2023 | 100 | 16-05-2023 | 15 |
B | 30-06-2023 | 120 | 27-06-2023 | 3 |
C | 31-07-2023 | 90 | 27-06-2023 | 34 |
Solved! Go to Solution.
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.
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.
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.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
145 | |
87 | |
66 | |
52 | |
45 |
User | Count |
---|---|
215 | |
90 | |
83 | |
66 | |
58 |