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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Chris878
Regular Visitor

Variance to prior weeks running sum

Hey,

 

i want to create a report showing revenue increases per calendar week (end of week) and the number of respective customer. I also want to calculate the KPI Revenue per Customer as running Sum for all Sales as shown in the table. I want to show the development of the last 6 weeks in the table however include all the previous weeks as well for the cumulated measures. And, to make it more complicated, i need the calendar weeks displayed be able to be filtered (Data Status as of "12.12.2024") in order to replicate old week statuses. Therefore a date table is existent.

 

in the example there are no entries before 01.01.2025, however in my real data the revenue would for example start already in 31.10.2024. In the end, i need the collumns "Revenue" and "Variance to prior week REV/Guest".

 

 01.01.2508.01.2515.01.2523.01.2531.01.25
Revenue5105105
Guests21212
Revenue per Guest2,5102,5102,5
Cumulated Rev515203035
Cumulated Rev/Guest2,554635/8
Variance to prior week REV/Guest +2,5-1+2-1,625



Can anyone help with the formula? I have been testing a lot but fail to find a solution in which the weeks are dynamicly shown in the table and the running sum is calculated based on that collumns without showing the collumns before the 6 weeks.

my current formular for the revenue is 

CALCULATE(SUM(Revenue.Table[Revenue]),DATESINPERIOD('Date Table Load Date'[Date],MAX('Date Table Load Date'[Date]),-42,DAY)),

for the collumns i have created a collumn in the Revenue.Table as "Date Last 6 Weeks" = RELATED ('Date Table Load Date'[End of Week]). A Filter for the 'Date Table Load Date'[Date] is placed on the page to have the dynamic date range of the 6 weeks



Thank you.

4 REPLIES 4
v-csrikanth
Community Support
Community Support

Hi @Chris878 
Thanks for confirming that issue has been resolved by using the above formula after your research.

If your issue is resolved, please consider marking the post as solved. However, if you're still facing challenges, feel free to share the details, and we'll be happy to assist you further.
Looking forward to your response!


Best Regards,
Community Support Team _ C Srikanth.

Chris878
Regular Visitor

Hey everyone,

 

i ended up using this formula after some more research and used it in a calculation group. It works fine for me. the table "Previous week" is used to filter for a specific time of data to be included based on the "Load date". the both date tables are not connected to each other.

Current Year Last 6 Weeks =

VAR currentweek = MAX('Date Table Previous Date'[End of Week])
VAR previousweek = currentweek-42
VAR periodtodate = FILTER(ALLSELECTED('Date Table Load Date'[End of Week]),'Date Table Load Date'[End of Week]<=MAX('Date Table Load Date'[End of Week]))
VAR periodtodatepriorweek = FILTER(ALLSELECTED('Date Table Load Date'[End of Week]),'Date Table Load Date'[End of Week]+7<=MAX('Date Table Load Date'[End of Week]))

RETURN
    IF(VALUES('Date Table Load Date'[End of Week])<=currentweek && VALUES('Date Table Load Date'[End of Week])>previousweek,
       
    CALCULATE(SELECTEDMEASURE(),REMOVEFILTERS('Date Table Load Date'[End of Week]),periodtodate)
     -
    CALCULATE(SELECTEDMEASURE(),REMOVEFILTERS('Date Table Load Date'[End of Week]),periodtodatepriorweek))
Ashish_Mathur
Super User
Super User

Hi,

Share some data to work with and show the expected result.  Share data in a format that can be pasted in an MS Excel file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
lbendlin
Super User
Super User

First step is to bring your data into a usable format.

 

lbendlin_0-1741047401088.png

Then fix the column types

lbendlin_1-1741047462245.png

Now you can create your measures

 

Revenue per Guest = DIVIDE(sum('Table'[Revenue]),sum('Table'[Guests]))

Cumulated Rev = CALCULATE(sum('Table'[Revenue]),WINDOW(1,ABS,0,REL,allselected('Table'[Date])))

 

And this is where you need to stop and think - does Cumulate Rev/Guest even make sense?  What if these are the same guests?

 

 

Cumulated Rev/Guest = 
var w = WINDOW(1,ABS,0,REL,allselected('Table'[Date]))
return divide(CALCULATE(sum('Table'[Revenue]),w),CALCULATE(sum('Table'[Guests]),w))

 

Which doesn't match your expected result.

 

lbendlin_2-1741047971526.png

 

Anyway, moving on.

 

Variance = 
var p = CALCULATE([Cumulated Rev/Guest],OFFSET(-1,allselected('Table'[Date])))
return if(not ISBLANK(p),[Cumulated Rev/Guest]-p)

 

 

lbendlin_4-1741048784592.png

 

 

 

 

 

 

 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors