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.
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.
Solved! Go to Solution.
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:
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.
Hope it helps.
Regards.
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:
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.
Hope it helps.
Regards.
Absolutley brilliant.
Thank you.
Yesterday was very, very frustrating.
Have a fabulus day.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
107 | |
97 | |
75 | |
65 | |
53 |
User | Count |
---|---|
144 | |
103 | |
98 | |
85 | |
64 |