Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
I have 2 tables, the first contains all the transactions(TransactionTable) and the second one contains all the dates (DateTable) from 1st Jan 2018 to 31st Dec 2021.
I have a expired date for each batch of my products stored in the inventory. I want to write a measure to calculate difference between expiry date and the date in the DateTable, to determine expired products. I have a seperate table for dates and the expiry date is in my transactions table. How to I compare dates from two different tables?
I want to plot a graph of Number of Expired products against the date. So I want to know on a certain date, how many products in stock will be expired.
Hi @Anonymous ,
Shouldn't the expiration date of the product be compared with today?
__DateDiff =
DATEDIFF(
TODAY(),
MAX(Sheet1[expiration_date]),
DAY
)
__Number of expiration =
CALCULATE(
COUNT(Sheet1[Product_id]),
FILTER(
Sheet1,
[__DateDiff] < 0
)
)
Best regards,
Lionel Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous ,
Has your problem been solved?
Best regards,
Lionel Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Copying DAX from this post? Click here for a hack to quickly replace it with your own table names
Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C
I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com
@Anonymous , Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.
Date diff = datediff(min(Transacation[Expiry Date]), Max(Date[Date]),Day)
But you need to force a context using values or summarize
Refer for context
I have tried to elaborate the question.
User | Count |
---|---|
140 | |
113 | |
104 | |
77 | |
65 |
User | Count |
---|---|
136 | |
118 | |
101 | |
71 | |
61 |