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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
UK06B1
Helper II
Helper II

Calculating weekly change of cumulative data

Hi 

I am trying to solve a problem i have. My data is on a cumulative basis (weekly data downloads). And I would like to calculate the weekly amounts. For example in the below table the worked hours is cumulating but i would like to return the value for each week. Therefore week 1 would be 22, week 2 = 58 hours (80-22) , week 3 = 54 (134-80) etc . I have spent a couple of hours on this now, which i thought would be a relatively straight forward solution. Any help would be greatly appreciated. 

 

NOTE: in my date table i have already created a week number, month number, year number column which i was using to try and solve using various measures, but failed. 

 

Thanks 

 

UK06B1_0-1620310825784.png

 

1 ACCEPTED SOLUTION

@UK06B1 

please  see the attachment below





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

15 REPLIES 15
ryan_mayu
Super User
Super User

@UK06B1 

you can create a column

Column = 
VAR _date=MAXX(FILTER('Table','Table'[date]<EARLIER('Table'[date])&&year('Table'[date])=year(EARLIER('Table'[date]))),'Table'[date])
return 'Table'[worked hours]-maxx(FILTER('Table','Table'[date]=_date),'Table'[worked hours])

1.png





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




This looks like it would work - howere is there a way to make it variable, in between date and worked hours column I have employee names - in which case i would like the new column to work out the hours worked in the week + by person. 

@UK06B1 

maybe you can try

Column =
VAR _date=MAXX(FILTER('Table','Table'[date]<EARLIER('Table'[date])&&employee=earlier(employee)&&year('Table'[date])=year(EARLIER('Table'[date]))),'Table'[date])
return 'Table'[worked hours]-maxx(FILTER('Table','Table'[date]=_date),'Table'[worked hours])

 

If you can provide the sample data and expected output, that will be better for us to provide the best solution





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




I can seem to attach any data to the thread - would a screen shot of some sample data, the data table and the expected outcome work ? thanks 

@UK06B1 

you can try that. Let's see if this will work.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




apologies for the delay - here is the snapshot of essentially the 2 tables of data (Employee - with cumulative hours worked to the week ending) | date table which i am using in the model | 3rd table essentially with the expected out come (Worked hours in the week - yellow column).

In the end I did use power query to get the solution i needed but that’s because of time - and resorting to alot of manual calc files - I would prefer to understand if/how this is possible as it will definitely be useful for the future.

Thanks for your help.

UK06B1_0-1620806634676.png

 

@UK06B1 

please  see the attachment below





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Brilliant that works  - thanks alot for your help. 

not be sure why you need the 3rd table. I think you can just create a column in employee table.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




yeah thats fine - it was just for presentation purposes - idea would be to get the highlighted col in the emplyee table -either through calculated column or some other means . thanks 

 

Anonymous
Not applicable

I don't understand what prevents you from calulating the weekly numbers in Power Query... or in the source.

the source data is 17 downloads (one for each week so far) with many columns and many different variables - in essence i could just use the source excel files and manually calculate but then i would need to do this for every variable (person) and ever week - plus there are new starters and people leaving so becomes very complictated when doing it in Excel (too large to cope with all the vlookups). I was hoping this would be as simpe as current week - previous week value for the set of filters defined (Person | Week/Date). ? which i could then use in the model to work out the week on week changes for all the other variables. 

 

Anonymous
Not applicable

@UK06B1 

 

As much as I understand, the separate files you get have the same structure. This makes it dead easy to import all of them into Power Query and make the calculations you're after. On top of that, if you do it the right way - which means in Power Query - you'll reduce complexity and your DAX will be not only simpler, but also more speedy.

 

I have a feeling you're trying to sqeeze a square into a round hole. Please do not. And do not re-invent the wheel. Please get familiar with Power Query and this will set you free 🙂

hi,  i am now in the same psiton in power query with virtually the same model which appears to be  a mirror of power BI. I still have the same issue where i have a table of data with thousands of rows for individual weeks per employee - with the cuulative hours for that week. How can now get this into a weekly view ? i have treid power pivot using the model - but still cannot get the weekly data - how would you suggest getting the weekly number - i presume a caclculated column? 

UK06B1_0-1620327408316.png

NOTE : the date column has dates running up to current date. With the week end being the sundays. 

 

thanks , i really dont mind which solution to be honest - i will give power query a try

Helpful resources

Announcements
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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