Forum Discussion
Inventory Calculation_DAX help
Reddyp , With help from a common date table
CALCULATE(SUM(Table[New Stock]),filter(date,date[date] <=maxx(date,date[date]))) - CALCULATE(SUM(Table[Out ]),filter(date,date[date] <=maxx(date,date[date])))
amitchandak Thanks for the reply
another question: Where can i fit this above mentioned DAX code into below code. the below mentioned DAX is designed to calculate inventory but now I need to update code for this old DAX measure where the deduction of inventory stock will happen based on branch name.
Old DAX measure:
Measure =
VAR __Date = MAX('Table'[Date])
VAR __InTable = FILTER(ALL('Table'),[New Stock] <> BLANK())
VAR __OutTable = FILTER(ALL('Table'),[Stock out] <> BLANK())
VAR __Out = SUMX(__OutTable,[Stock out])
VAR __ResultTable =
ADDCOLUMNS(
ADDCOLUMNS(
__InTable,
"__RunningTotal",SUMX(FILTER(__InTable,[Date]<=__Date),[New Stock])
),
"__WhileLoop",[__RunningTotal] - __Out
)
VAR __Result = MAXX(FILTER(__ResultTable,[Date] = __Date),[__WhileLoop])
RETURN
IF(__Result <= 0,0,__Result)