Forum Discussion
darylmc
6 years agoFrequent Visitor
Measure - same day last week per column
Hi All, I'm looking to create a measure for availability for the same day last week. I've created the following formula which mostly works LW Avail = calculate(Divide(Sum(History[avail_sum])...
- 6 years ago
Hi, darylmc ,
you could write your measure like this:
LW Avail = VAR _product = CALCULATE ( SELECTEDVALUE ( History[Product] ) ) VAR _date = CALCULATE ( MAX ( History[Date] ) ) VAR _store = CALCULATE ( SELECTEDVALUE ( History[Store] ) ) RETURN IF ( HASONEVALUE ( History[Product] ), CALCULATE ( DIVIDE ( SUM ( History[avail_sum] ), SUM ( History[avail_count] ), "" ), FILTER ( ALL ( History ), History[Date] = _date - 7 && History[Store] = _store && History[Product] = _product ) ), CALCULATE ( DIVIDE ( SUM ( History[avail_sum] ), SUM ( History[avail_count] ), "" ), FILTER ( ALL ( History ), History[Date] = _date - 7 && History[Store] = _store ) ) )Cheers,
Sturla
sturlaws
6 years agoResident Rockstar
Hi, darylmc ,
you could write your measure like this:
LW Avail =
VAR _product =
CALCULATE ( SELECTEDVALUE ( History[Product] ) )
VAR _date =
CALCULATE ( MAX ( History[Date] ) )
VAR _store =
CALCULATE ( SELECTEDVALUE ( History[Store] ) )
RETURN
IF (
HASONEVALUE ( History[Product] ),
CALCULATE (
DIVIDE ( SUM ( History[avail_sum] ), SUM ( History[avail_count] ), "" ),
FILTER (
ALL ( History ),
History[Date] = _date - 7
&& History[Store] = _store
&& History[Product] = _product
)
),
CALCULATE (
DIVIDE ( SUM ( History[avail_sum] ), SUM ( History[avail_count] ), "" ),
FILTER ( ALL ( History ), History[Date] = _date - 7 && History[Store] = _store )
)
)
Cheers,
Sturla
darylmc
6 years agoFrequent Visitor
Works like a charm!
Thanks