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! Request now

Reply
Anonymous
Not applicable

DAX: Carry forward previous calculated value at yearly and organization level with filters

I have a table as below image where I have data of New joinees and exits of employees at orgonization level for every months for multiple years.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("dZJBDoQwCAD/4tlNCrXqHrc8w/j/b2ythYBgsnqZSKezHMeU4NN+mDBN8/RrD2B7Ted8IzQoaZQ1WvrDaDHoYiCsaIa5vTZhqxNBYZtm5ZpZhO1u5lfY17gUdQNIGmXUmgBu5C4MnUqW4+S7Oqr4lLUfFJWsfVRYsrJGUJKPCkLyxKBj7ZnCjP2wuKJ4+IqsEURkjaDhhdY4IQ0EviENw+IjMso+IvUvrqGuIQ3DoCF18bAhvTek8S+jb0i83eAj0ntE6nrqYoDPUo+IoC6GNiKE9lkjuwGLQXoD7ogQyd8RtcZuI0Iovz8R2IjasNiGGmXbkJHZAMCnYduA8w8=", 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"

 

now as per below image, when i filter the org values from slicer it should give the output of active consultants as below image where it should give the active consultants for example:

for

JAN-2020 --> previous month active emp count + new joinees-exits = active consultants

6-1 = 5

FEB-2020 --> Till Jan Active consultants count+new joinees- exits

5+2-5=2

 

Mohan1029_0-1645794859076.png

I am able to get it by below dax measure query

Active Consultants = 
calculate(sum('Table'[New Joinees]) - sum('Table'[exits]), filter(allselected('Table'), 'Table'[Org ID] = max('Table'[Org ID]) && 'Table'[Date] <= max('Table'[Date])))

Mohan1029_2-1645795367448.png

But when i filter at Year slicer as 2021, the values are not getting carry forward it is doing the cumulative sum for that year only.

Mohan1029_5-1645795745481.png

 

 

where as, as per our requirement, while calculating active consultants, even after filtering the data at org level and also at year or month level, the previous months active consultants values should be carry forward to the next year or next month

as below image.

Mohan1029_4-1645795675153.png

 

At months level filters with curret dax,

Mohan1029_6-1645795790571.png

Required output,

Mohan1029_7-1645795877417.png

 

As i am going to show case the same measure into card visuals as well. so it should work with card visuals as well.

At year level - it should give the last months active consultants value.

At month level - it should give the selected months active consultants value.

Any help or suggestions how can i solve this.

 

Thanks,

Mohan V.

 

 

 

1 ACCEPTED SOLUTION
v-chenwuz-msft
Community Support
Community Support

 

Hi @Anonymous ,

 

I recommend you create a column to get the result rather than measure. As you description, the cumulative sum won't change when you do some change on slicer.

 

cumulative sum =
CALCULATE (
    SUM ( 'Table'[New Joinees] ) - SUM ( 'Table'[Exits] ),
    FILTER (
        'Table',
        [Org ID] = EARLIER ( 'Table'[Org ID] )
            && [Date] <= EARLIER ( 'Table'[Date] )
    )
)

 

 

But if you need measure to do that, please try this expression, replace the ALLSELECTED with ALL.

 

Active Consultants = CALCULATE ( SUM ( 'Table'[New Joinees] ) - SUM ( 'Table'[exits] ), FILTER ( ALL ( 'Table' ), 'Table'[Org ID] = MAX ( 'Table'[Org ID] ) && 'Table'[Date] <= MAX ( 'Table'[Date] ) ) )

 

Result:

 

vchenwuzmsft_0-1646120357718.png

 

 

 

Pbix in the end you can refer.

Best Regards

Community Support Team _ chenwu zhu

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

6 REPLIES 6
v-chenwuz-msft
Community Support
Community Support

 

Hi @Anonymous ,

 

I recommend you create a column to get the result rather than measure. As you description, the cumulative sum won't change when you do some change on slicer.

 

cumulative sum =
CALCULATE (
    SUM ( 'Table'[New Joinees] ) - SUM ( 'Table'[Exits] ),
    FILTER (
        'Table',
        [Org ID] = EARLIER ( 'Table'[Org ID] )
            && [Date] <= EARLIER ( 'Table'[Date] )
    )
)

 

 

But if you need measure to do that, please try this expression, replace the ALLSELECTED with ALL.

 

Active Consultants = CALCULATE ( SUM ( 'Table'[New Joinees] ) - SUM ( 'Table'[exits] ), FILTER ( ALL ( 'Table' ), 'Table'[Org ID] = MAX ( 'Table'[Org ID] ) && 'Table'[Date] <= MAX ( 'Table'[Date] ) ) )

 

Result:

 

vchenwuzmsft_0-1646120357718.png

 

 

 

Pbix in the end you can refer.

Best Regards

Community Support Team _ chenwu zhu

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

johnt75
Super User
Super User

Try

Active Consultants = 
var maxDate = MAX( 'Table'[Date] )
return CALCULATE( SUMX('Table', 'Table'[New Joinees] - 'Table'[Exits] ),
REMOVEFILTERS('Table'[Date]),
'Table'[Date] <= maxDate
)

You need to remove the filters on date so that you can include everything before the currently selected date, not just rows which are in that time period

Anonymous
Not applicable

Hi @johnt75 ,

 

Thanks for the reply.

much appreciate it.

 

I did change the measure formula but it is not working as expected.

 

When i do filter the year values or month values, the previous month or year active consultant values should be inlcuded in current month or year calculations as below image.

 

**Expected Output when we filter year Slicer values**

 

Mohan1029_0-1645800453079.png

But, as per your measure, it is still the same as earlier.

Mohan1029_1-1645800510311.png

**Expected Output when we filter Year and Month Slicer values**

Mohan1029_2-1645800582139.png

 

Please help.

 

Thanks,

Mohan V.

Where are the Year and Month columns coming from? You need to use REMOVEFILTERS on those as well

Anonymous
Not applicable

Hi @johnt75 , Both Year and Month slicers are coming from same table. I took hierarchial Date slicer and from that, removed Qtr, Month, Day for Year slicer and For Months Slicer, removed Year, Qtr, Day from hierarchy.

 

Right, I understand now. The filters are actually being applied to a local date table which Power BI is creating automatically. There are a couple of options. If you only want to group the results by organization then you can replace the REMOVEFILTERS line with  ALLEXCEPT('Table', 'Table'[Org ID]). If you're going to want to group or slice by other columns as well then you'd need to create a date table, link that to your current table and use slicers from the new date table rather than the existing table.

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