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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
jankooy
New Member

Cumulative total more than current value using current filters

I am working on a survival analysis for a large list of assets.  I want to use the current filters to update the analysis.  I need to have a cumulative total for the assets that calculates the total number of assets that are less than the current age.  Something like this

 

Asset AgeCount at ageCumulative total
055
11015
21530

where the cumulative total is the number of assets that are less than or equal to the current asset age.  

A quick look on the web suggests doing this to calculate the cumulative total:

Cumulative Total = COUNTROWS(FILTER(ALL(ASSET),ASSET[Calc_Age]<=MAX(ASSET[Calc_Age])))
 
 I don't want the "ALL" filter as I want to use the current filters that are set.  If I leave the "ALL" in the filter expression, the cumulative total works but it uses all of the assets in the list.  I would like to do something like:
Cumulative Total = COUNTROWS(FILTER(KEEPFILTERS(ASSET),ASSET[Calc_Age]<=MAX(ASSET[Calc_Age])))
Problem is this doesn't work.  The result is just the count at the specific age.  Something like this:
Asset AgeCount at ageCumulative total
055
11010
21515
 
Is there a way to create a measure that will use the current filters in addition to the filtering by age so that the analysis can be dynamic?  
1 ACCEPTED SOLUTION
cengizhanarslan
Super User
Super User

I am not exactly sure what you ask but I far as I understand this could help:

Cumulative Total =
COUNTROWS (
    FILTER (
        ALLSELECTED ( 'ASSET' ),
        'ASSET'[Calc_Age] <= MAX ( 'ASSET'[Calc_Age] )
    )
)

 

_________________________________________________________
If this helped, ✓ Mark as Solution | Kudos appreciated
Connect on LinkedIn | Follow on Medium
AI-assisted tools are used solely for wording support. All conclusions are independently reviewed.

View solution in original post

6 REPLIES 6
parry2k
Super User
Super User

I have no idea why you all will reply even if you are not sure what the ask is and are asking the same question. Just my 2 cents. Cheers!



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

johnt75
Super User
Super User

You can use 

Cumulative Total =
VAR MaxAge =
    MAX ( ASSET[Calc_Age] )
VAR Result =
    CALCULATE ( COUNTROWS ( ASSET ), ASSET[Calc_Age] <= MaxAge )
RETURN
    Result

This will keep any filters already in place but replace the filter on Calc_Age, coming from the visual.

If the calc age happens to be sorted by a different column then you would also need to remove the filters from the sort by column, e.g.

Cumulative Total =
VAR MaxAge =
    MAX ( ASSET[Calc_Age] )
VAR Result =
    CALCULATE (
        COUNTROWS ( ASSET ),
        ASSET[Calc_Age] <= MaxAge,
        REMOVEFILTERS ( ASSET[Sort by column] )
    )
RETURN
    Result
xifeng_L
Super User
Super User

Hi @jankooy 

 

As I understand it, you want to accumulate the asset quantity while keeping the other slicers effective.

 

To achieve this requirement, you only need to accumulate based on Asset Age. You can try the following measure:

 

Cumulative Total = 
VAR tempTbl = ADDCOLUMNS(ALL(ASSET[Asset Age]),"Asset Count",[Count at age])
VAR CurRowAge = MAX(ASSET[Asset Age])
RETURN
SUMX(
    FILTER(tempTbl,ASSET[Asset Age]<=CurRowAge),
    [Asset Count]
)

 

Since I’m not sure about your table structure, the table names and column names are based on the example table you provided. You can change them to your actual column names.

 

In addition, if [Count at age] is not a measure, but is obtained by directly dragging a field into the table, then you can replace it with the following expression:

 

Count at age = CALCULATE(COUNT(ASSET))

 

 

Did I answer your question? If yes, pls mark my post as a solution and appreciate your Kudos !

 

Thank you~

cengizhanarslan
Super User
Super User

I am not exactly sure what you ask but I far as I understand this could help:

Cumulative Total =
COUNTROWS (
    FILTER (
        ALLSELECTED ( 'ASSET' ),
        'ASSET'[Calc_Age] <= MAX ( 'ASSET'[Calc_Age] )
    )
)

 

_________________________________________________________
If this helped, ✓ Mark as Solution | Kudos appreciated
Connect on LinkedIn | Follow on Medium
AI-assisted tools are used solely for wording support. All conclusions are independently reviewed.

Thank you.  This works.  Tried "KEEPFILTERS" but that did not work.  "ALLSELECTED" does.  

parry2k
Super User
Super User

@jankooy are you saying you need a cumulative total by each asset? Sorry, your question is not clear. Can you add more rows of the same asset and provide the expected output? The current sample data and output is hard to understand what exactly you are looking for.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.