Forum Discussion

a68tbird's avatar
a68tbird
Icon for Resolver II rankResolver II
8 years ago
Solved

Calculate 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

  • johnmc's avatar
    johnmc
    Frequent Visitor

    Hi - i think you want...

     

    TotalSales30Day =
    CALCULATE (
        SUM ( Orders[Quantity] ),
        DATESINPERIOD ( CalendarTable[Date], LASTDATE ( CalendarTable[Date] ), -30, DAY )
    )

     

     

    • a68tbird's avatar
      a68tbird
      Icon for Resolver II rankResolver II

      Thanks johnmc, but that didn't seem to do anything for me either.

      • v-cherch-msft's avatar
        v-cherch-msft
        Icon for Microsoft Employee rankMicrosoft 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