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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Casperserven1
Helper I
Helper I

Accumulating using previous

I am trying to do tthe following and struggling - I am sure this is easy but just can't see it.
New HiresRetireesTotal Workforce
3520
6323
8130
9831
4629
3131
2132
7831

So in excel my first row = 22 +New Hires - Retirees

My second row = 20 (the result from the previous row) +NewHires - Retirees
My third row    = 23  (the result from the previous row) +NewHires - Retirees
etc.. 
Tried various things including EARLIER, using indexing, 

1 ACCEPTED SOLUTION

@Casperserven1

Now I got it. Please try

Total Workforce =
VAR StartingWF = 22
VAR TableBefore =
FILTER ( 'Table', 'Table'[Date] < EARLIER ( 'Table'[Date] ) )
VAR Change =
SUMX ( TableBefore, 'Table'[New Hires] - 'Table'[Retirees] )
RETURN
StartingWF + Change

View solution in original post

10 REPLIES 10
tamerj1
Super User
Super User

Hi @Casperserven1 
Is this a data table or a table visual? How did you get the first value (22)?

and this is the raw data.

@Casperserven1 
Please refer to attached sample file with the proposed solution

1.png

Total Workforce = 
VAR StartingWF = 22
VAR TableOnAndBefore = 
    FILTER ( 'Table', 'Table'[Date] <= EARLIER ( 'Table'[Date] ) )
VAR Change = 
    SUMX ( TableOnAndBefore, 'Table'[New Hires] - 'Table'[Retirees] )
RETURN
    StartingWF + Change

Casperserven1_0-1686749775909.png

Thanks the pbix worked perfectly, however when I tried the technique with other data this is what occurred...any ideas??

@Casperserven1 
It should be a calculated column not a measure!

Thankyou so much , unfortunately it still isn't right. We only want the starting figure of 22 in the first row. after that is thould be adding and subtracting from the previous row.

 

@Casperserven1 
Please clarify further. Perhaps with a screenshot?

yeah sure

 

Casperserven1_0-1686754366257.png

 

@Casperserven1

Now I got it. Please try

Total Workforce =
VAR StartingWF = 22
VAR TableBefore =
FILTER ( 'Table', 'Table'[Date] < EARLIER ( 'Table'[Date] ) )
VAR Change =
SUMX ( TableBefore, 'Table'[New Hires] - 'Table'[Retirees] )
RETURN
StartingWF + Change

The first value (22) is the starting workforce.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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