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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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.