Forum Discussion

iNekros's avatar
iNekros
New Member
10 years ago
Solved

DAX: Calculate, Filter problem, dead stock calculation

Hey guys,

Im still new to DAX. Im trying to calculate measure which is called Dead stock. The measure definition is following, its Inventory status for items, which havent been sold for 8 previous weeks. So I have calculated measure for sum of last 8 week sales.

[sumSalesLast8weeks]=CALCULATE([TotalSales],
DATESINPERIOD(DateByDay[DateKey],
LASTDATE(DateByDay[DateKey]),-56, Day
)
)

 

and then Im trying to use calculate with filter to calculate only sum of inventory where last 8 week sales equals 0
[DeadInventory]=CALCULATE(sum(FactTable[Inventory]),FILTER(FactTable,[sumSalesLast8weeks]=0))

but the problem is following that filter only values where are current week sales are zero, not the last 8 weeks sales are zero.

Do you have any advices, how to solve this problem?

 

Best regards

iNekros

3 Replies

  • mmm.

    In my opinion is wrong by desing:

    I'd preferred a calculated COLUMN on the Fact table that calculate the [sumSalesLast8weeks] and use a IF statement that puts a value like ACTIVE if >0 or DEAD if = 0.

     

    isn't it better? Then u can easily filter by that column.