Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code FABINSIDER for a $400 discount.
Register nowThe Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.
I want to analyze our purchase orders and check it against the inventory audit log to analyze the inventory levels for that date. I have attached my file with sample data and details. The main issue is the audit table only records changes so when using a calendar table, it is not aligning with all audit dates so I need to find the qty of the previous date recorded for that product and warehouse.
https://drive.google.com/file/d/1mhFoVVxsnHDGDhF2ebT5FVoU9P_EkPN0/view?usp=sharing
Purchase Orders
Date
Project
PO Number
Product ID
Warehouse
Qty Purchased
Inventory Audit
Date
Product ID
Warehouse
Qty Changed
Qty On Hand
Calendar Table
Date
Expected Results
Solved! Go to Solution.
For your question, here is the method I provided:
Create measures.
Project Number =
CALCULATE(
MAX('Purchase Orders'[Project Number]),
FILTER(
ALL('Purchase Orders'),
'Purchase Orders'[Date Purchased] = MAX('Purchase Orders'[Date Purchased])
)
)
Qty On Hand =
var _date = SELECTEDVALUE('Purchase Orders'[Date Purchased])
var _maxdate =
CALCULATE(
MAX('Inventory Audit GROUPED'[Date]),
FILTER(
ALL('Inventory Audit GROUPED'),
'Inventory Audit GROUPED'[Date] <= _date
&&
'Inventory Audit GROUPED'[Warehouse] = SELECTEDVALUE('Purchase Orders'[Warehouse])
)
)
RETURN
CALCULATE(
SELECTEDVALUE('Inventory Audit GROUPED'[Qty On Hand]),
FILTER(
ALL('Inventory Audit GROUPED'),
'Inventory Audit GROUPED'[Date] = _maxdate
)
)
Here is the result.
Regards,
Nono Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
For your question, here is the method I provided:
Create measures.
Project Number =
CALCULATE(
MAX('Purchase Orders'[Project Number]),
FILTER(
ALL('Purchase Orders'),
'Purchase Orders'[Date Purchased] = MAX('Purchase Orders'[Date Purchased])
)
)
Qty On Hand =
var _date = SELECTEDVALUE('Purchase Orders'[Date Purchased])
var _maxdate =
CALCULATE(
MAX('Inventory Audit GROUPED'[Date]),
FILTER(
ALL('Inventory Audit GROUPED'),
'Inventory Audit GROUPED'[Date] <= _date
&&
'Inventory Audit GROUPED'[Warehouse] = SELECTEDVALUE('Purchase Orders'[Warehouse])
)
)
RETURN
CALCULATE(
SELECTEDVALUE('Inventory Audit GROUPED'[Qty On Hand]),
FILTER(
ALL('Inventory Audit GROUPED'),
'Inventory Audit GROUPED'[Date] = _maxdate
)
)
Here is the result.
Regards,
Nono Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thank you! This worked perfectly. The performance is very slow but it works!
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the February 2025 Power BI update to learn about new features.
User | Count |
---|---|
25 | |
12 | |
9 | |
9 | |
9 |
User | Count |
---|---|
19 | |
14 | |
14 | |
13 | |
12 |