Skip to main content
cancel
Showing results for 
Search instead 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.

Reply
CABIRDUK
Helper II
Helper II

Date column - last thirty days and total sales

I have a table with Date & Sales figures.

 

I want a rolling measure to be able to extract the last 30 days a total number of sales? For example last 30 days a total number of sales was 200.

 

I have spent a full day researching forums, blogs, videos and haven't quite been able to find a suitable solution. I require automated solution i.e. user not asked to enter a date. New date and sales figures are added each month. 

 

Thank you for reading this message and any assistance you may offer. 

1 ACCEPTED SOLUTION
MarcoRotta
Resolver I
Resolver I

Hi CABIRDUK.

 

It seems that you need a rolling sum for the last X periods of time, right? Let me show you one way to do that.

 

 

As you haven't shared any data set, let me use the following table (loaded as "Test") to demonstrate:

 

Capture.PNG

 

Now I've added a measure with the following DAX formula to calculate the rolling sum of the last X days. Hopefully, you'll be able to understand the formula as you read it:

 

Rolling sum = CALCULATE(sum(Test[Sales]),
          DATESINPERIOD(Test[Date],
                        LASTDATE(Test[Date]),-5, DAY
                       )
         )

 

I'm calculating the rolling sum of the last 5 days here (my dataset is not that large), but you can change to 30 or anything you like. 

 

Then, just added the measure to a visual, and here we go.

 

Capture2.PNG

Hope it helps.

Regards.

View solution in original post

2 REPLIES 2
MarcoRotta
Resolver I
Resolver I

Hi CABIRDUK.

 

It seems that you need a rolling sum for the last X periods of time, right? Let me show you one way to do that.

 

 

As you haven't shared any data set, let me use the following table (loaded as "Test") to demonstrate:

 

Capture.PNG

 

Now I've added a measure with the following DAX formula to calculate the rolling sum of the last X days. Hopefully, you'll be able to understand the formula as you read it:

 

Rolling sum = CALCULATE(sum(Test[Sales]),
          DATESINPERIOD(Test[Date],
                        LASTDATE(Test[Date]),-5, DAY
                       )
         )

 

I'm calculating the rolling sum of the last 5 days here (my dataset is not that large), but you can change to 30 or anything you like. 

 

Then, just added the measure to a visual, and here we go.

 

Capture2.PNG

Hope it helps.

Regards.

Absolutley brilliant.

 

Thank you. 

 

Yesterday was very, very frustrating. 

 

Have a fabulus day.

Helpful resources

Announcements
Microsoft Fabric Learn Together

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

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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