Forum Discussion

Sperling's avatar
Sperling
Icon for Advocate II rankAdvocate II
1 year ago
Solved

Count days with filters

I have a fact table with items and a dummy for whether the item is deadstock or not.

This is stamped on the items each day, so we can see the history of the items we have.

 

The fact table is connected to our item dimension, the date dimension and the deadstock time dependent dimension.

 

I want to create a measure that calculates how long the item has been deadstock IF it currently is deadstock.

I've approached this in a few different ways without luck.

 

Below is an image of a random item that is currently marked as deadstock:

 

The value I'm interested in here is 9.

 

I figured it was as simple as:

1. finding the max date where Deadstock = No

2. finding the max date where Deadstock = Yes

3. making sure the measure only calculates for cases where Deadstock on today() - 1 = Yes (important)

4. and then finally counting the rows

 

I can't just count rows where Deadstock = Yes, since I don't want to include old periods where it was Deadstock, only the current period.

 

It has proved more difficult than anticipated, so I'm open to suggestions.

 

5 Replies