Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
a68tbird
Resolver II
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 Smiley Wink 😞

 

 

image.png

 

Thoughts?

Thanks

Travis

 

 

 

1 ACCEPTED SOLUTION

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

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.

View solution in original post

4 REPLIES 4
johnmc
Frequent Visitor

Hi - i think you want...

 

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

 

 

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

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

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.

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! 

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Fabric Monthly Update - May 2024

Check out the May 2024 Fabric update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.