Forum Discussion
a68tbird
Resolver II
8 years agoCalculate Sales Past 30 Days
Hello All -
I can't quite figure out why my formula isn't working here. I'm trying to calculate the sales from the past 30 months using the following:
TotalSales30Day =
CALCULATE (
SUM ( Orders[Quantity] ),
DATESINPERIOD ( CalendarTable[Date], MAX ( CalendarTable[Date] ), -30, DAY )
)but the result is blank. My CalendarTable is related to the sales table date.
The Dates columns are formatted as Date (not Date/Time). Quantity is a whole number.
Here's a snapshot of the Orders table (and yes, sales go back much further than today :smileywink: ):
Thoughts?
Thanks
Travis
Hi a68tbird
It seems you may try to use below measure:
TotalSales30Day = CALCULATE ( SUM ( Orders[Quantity] ), DATESINPERIOD ( Orders[OrderDate], MAX ( Orders[OrderDate] ), -30, DAY ) )Regards,
Cherie
4 Replies
- johnmcFrequent Visitor
Hi - i think you want...
TotalSales30Day = CALCULATE ( SUM ( Orders[Quantity] ), DATESINPERIOD ( CalendarTable[Date], LASTDATE ( CalendarTable[Date] ), -30, DAY ) )- a68tbird
Resolver II
Thanks johnmc, but that didn't seem to do anything for me either.
- v-cherch-msft
Microsoft Employee
Hi a68tbird
It seems you may try to use below measure:
TotalSales30Day = CALCULATE ( SUM ( Orders[Quantity] ), DATESINPERIOD ( Orders[OrderDate], MAX ( Orders[OrderDate] ), -30, DAY ) )Regards,
Cherie