cancel
Showing results for
Did you mean:

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Resolver II

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  😞

Thoughts?

Thanks

Travis

1 ACCEPTED SOLUTION
Employee

It seems you may try to use below measure:

TotalSales30Day =
CALCULATE (
SUM ( Orders[Quantity] ),
DATESINPERIOD ( Orders[OrderDate], MAX ( Orders[OrderDate] ), -30, DAY )
)

Regards,

Cherie

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
4 REPLIES 4
Frequent Visitor

Hi - i think you want...

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

Resolver II

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

Employee

It seems you may try to use below measure:

TotalSales30Day =
CALCULATE (
SUM ( Orders[Quantity] ),
DATESINPERIOD ( Orders[OrderDate], MAX ( Orders[OrderDate] ), -30, DAY )
)

Regards,

Cherie

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Resolver II

Thanks Cherie. That did work. I guess there's something wrong with my relationship between the calendar table and orders table? I can't understand why my original formula didn't work. All other examples of this formula that I've seen, use reference to the calandar table.

But all good!

Announcements

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors