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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

DAX: Calculate active employee count by Carry forward previous calculated value to next row

Hello All,

 

I have a requirement to calculate the active emplopyees using dax and the data follows as below.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("bZBLDsUgCEX34rhNAGs/w7KNpvvfxlP6IBhIxMmJl+t5ngK49kNAUJZy90HqV3mXD9GEwKPq0SajaJvQYGiseUa1X4exPRQhY4dnbWQ2Y2fIvIxdU5fmfoDgUSVfEzFEnsYoVKm2zt7x30pUybIoM8kSlZpkrZGY1FWJSE1MPLJoSjXKstyi9YgWtUYiUWskDgfaP4XvDw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, #"Org ID" = _t, #"New Joinees" = _t, Exits = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Org ID", type text}, {"New Joinees", Int64.Type}, {"Exits", Int64.Type}})
in
    #"Changed Type"

 

Mohan1029_0-1641901396739.png

every month for each org, i need to calculate the total active employees as Newjoinees-exits.

But while calculating the new joinees i need to consider the previous month count +current month new joinees-exits of this month.

Output and the formula mentioned as below image.

Mohan1029_1-1641901521632.png

I am able to get the running count and do the calculation of running count new joinees - exits but unable to carry forward that value to the next row to calculate the same.

 

Can any one please help me on this.

 

Thanks in advance.

 

Mohan V.

 

1 ACCEPTED SOLUTION
v-jingzhang
Community Support
Community Support

Hi @Anonymous 

 

You can create a new column with below DAX. Replace Query1 with your table name. 

Column = 
SUMX (
    FILTER (
        Query1,
        Query1[Org ID] = EARLIER ( Query1[Org ID] )
            && Query1[Date] <= EARLIER ( Query1[Date] )
    ),
    Query1[New Joinees] - Query1[Exits]
)

22011401.jpg

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

View solution in original post

2 REPLIES 2
v-jingzhang
Community Support
Community Support

Hi @Anonymous 

 

You can create a new column with below DAX. Replace Query1 with your table name. 

Column = 
SUMX (
    FILTER (
        Query1,
        Query1[Org ID] = EARLIER ( Query1[Org ID] )
            && Query1[Date] <= EARLIER ( Query1[Date] )
    ),
    Query1[New Joinees] - Query1[Exits]
)

22011401.jpg

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

amitchandak
Super User
Super User

@Anonymous , new measure or column in DAX

 

new measure =
calculate(sum(Table[New joinee]) - sum(Table[exits]), filter(allselected(Table), Table[Org ID] = max(Table[Org ID]) && Table[Date] <= max(Table[Date])))


New column
sumx( filter(allselected(Table), Table[Org ID] = max(Table[Org ID]) && Table[Date] <= max(Table[Date])), [New joinee] - [exits] +0)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

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.

Top Solution Authors