Forum Discussion
last n days
- 9 years ago
Hi Mark,
It is the context that makes the result right or wrong. When you have a context such as dates. You could try this formula to have a test.
Last 5 days 1 = CALCULATE ( SUM ( Sales[Qty Sold] ), DATESINPERIOD ( 'Sales'[Date], MIN ( Sales[Date] ), -5, DAY ) )
If you want to use your formula in a card visualization, you need to make a little change. It's still the context that makes the tricks. The card visualization takes the whole dataset as context.
Last 5 days 2 = VAR L5D = LASTDATE ( Sales[Date] ) - 5 RETURN CALCULATE ( SUM ( Sales[Qty Sold] ), FILTER ( ALL ( Sales ), Sales[Date] > L5D ) )Best Regards!
Dale
Hi Mark,
Have you tried something like this:
Sales Last 5 days = Calculate ( Sum ( Sales[Qty Sold]) , DateDiff ( Sales[Date] , Now() , DAY ) < 5 )
Alternately you could create a calculated column as follows and then add this in as a visual level filter:
Is Last 5 days = If ( DateDiff ( Sales[Date] , Now() , DAY ) < 5 , "Yes" , "No" )
Thanks,
J
- 67nmark9 years ago
Helper I
Thanks, I couldn't get your Sales Last 5 days measure to produce the result - it was doing the same as my measure and seemingly not recognising the date.