Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreWe'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
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 Age | Count at age | Cumulative total |
| 0 | 5 | 5 |
| 1 | 10 | 15 |
| 2 | 15 | 30 |
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:
| Asset Age | Count at age | Cumulative total |
| 0 | 5 | 5 |
| 1 | 10 | 10 |
| 2 | 15 | 15 |
Solved! Go to Solution.
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] )
)
)
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.
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
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~
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] )
)
)
Thank you. This works. Tried "KEEPFILTERS" but that did not work. "ALLSELECTED" does.
@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.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 8 | |
| 8 | |
| 3 | |
| 3 | |
| 2 |
| User | Count |
|---|---|
| 23 | |
| 13 | |
| 10 | |
| 6 | |
| 5 |