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
Lenastray
Helper I
Helper I

Dax formula to calculate inventory using the production and expiration date

Thanks for any assistance. In the data, we have a date table, and a table with the columns production date, item, amount and expiration date. My request is for creating a measure that calculate the current amount for any item at any given date (considering that production of any item happens more than once), as an alternative to creating the snapshot by etl.

 

Thanks for the support 

 

 

1 ACCEPTED SOLUTION
az38
Community Champion
Community Champion

Hi @Lenastray 

if I understand you correct you can try to create a measure in your date table like

Measure = 
var _currentDate = MAX('DateTable'[Date])
RETURN
CALCULATE(SUM(Table[Amount]), Table[production date] <= _currentDate, Table[expiration date] >= _currentDate)

do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

View solution in original post

4 REPLIES 4
lbendlin
Super User
Super User

Put your day column from the dates table into the visual that you want to use, and then create a measure that calculates the amount of products for each day where the production date is in the past and the expiration date is in the future.

 

Show some sample data and expected result.

az38
Community Champion
Community Champion

Hi @Lenastray 

if I understand you correct you can try to create a measure in your date table like

Measure = 
var _currentDate = MAX('DateTable'[Date])
RETURN
CALCULATE(SUM(Table[Amount]), Table[production date] <= _currentDate, Table[expiration date] >= _currentDate)

do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

Works great. Thanks! Az38. Which filter is recommended in calculate if we want to have the inventory for every day independent if there is a production of some item or not. 

Did you get resolution to this follow up question? I have the same question.

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