Forum Discussion
Michael92
1 year agoFrequent Visitor
DAX calculation
Hello all, I need to calculate the Stock - Request difference in the Matrix table. I always see only 3 days, yesterday, today and tomorrow. I need to calculate the current stock situation. I need to...
- 1 year ago
Hello,
thanks for your feedback. It gave me zero values everywhere.
But meanwhile i found a solution. This works for me:
Difference =CALCULATE(SUM('Table'[Stock]) - SUM('Table'[Request]),FILTER(ALL(Date_table), Date_table[Date]<= MAX(Date_table[Date])))
shafiz_p
1 year agoSuper User
Hi Michael92 Try below code:
Diff =
VAR CurrentDate = MAX('Table'[Date])
VAR StockOnDate =
CALCULATE(
[Stock'],
'Table'[Date] = CurrentDate
)
VAR RequestsUpToDate =
CALCULATE(
[Request'],
'Table'[Date] <= CurrentDate
)
RETURN
StockOnDate - RequestsUpToDateWhere :
[Stock'] = SUM('Table'[Stock])
[Request'] = SUM('Table'[Request])
Output:
Considering Dataset:
Hope this helps!!
If this solved your problem, please accept it as a solution and a kudos!!
Best Regards,
Shahariar Hafiz
- Michael921 year agoFrequent Visitor
Hello,
thanks for your feedback. It gave me zero values everywhere.
But meanwhile i found a solution. This works for me:
Difference =CALCULATE(SUM('Table'[Stock]) - SUM('Table'[Request]),FILTER(ALL(Date_table), Date_table[Date]<= MAX(Date_table[Date])))