Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
mjamesking
Creator
Creator

Straight table running total

Hi,

I would like to create a straight table in the following format

StockStock ValueWeightRunning Weight Total
Bananas10.33330.3333
Apples2.20.22220.5555
Pears3.130.10.6555
Peaches4.120.10.7555
Apricots5.880.150.9055
.................

Where I hold the Stock, Value and Weight in my data model and I'm calculating the Running Weight total where the Running Weight Total is the SUM of all the Weights of each Stock where the Stock Value is less than or equal to the Stock Value of the Stock I'm calculating it for.

I'd like to be able to do this in a chart expression rather than in the script so that I can chop and change the stocks that are in scope for the calculation and have the Running Weight Total recalculate.

Any ideas?

Thanks

Matt

1 Solution

Accepted Solutions
settu_periasamy
Master III
Master III

Hi,

You can try this in two way. In Expression Tab -> Full Accumulation

OR

You can use the below expression

=Rangesum(Above(TOTAL Sum(Weight),0,rowno(TOTAL)))

View solution in original post

5 Replies
settu_periasamy
Master III
Master III

Hi,

You can try this in two way. In Expression Tab -> Full Accumulation

OR

You can use the below expression

=Rangesum(Above(TOTAL Sum(Weight),0,rowno(TOTAL)))

Gysbert_Wassenaar

Try rangesum(above(sum(Weight),0,rowno())) as expression for the Running Weight Total


talk is cheap, supply exceeds demand
mjamesking
Creator
Creator
Author

Thanks both - can you think of how to highlight the first row where a threshold is breached. For instance if I set a threshold as 50% of the total 'weight' and sort the table by value I want to highlight the first row where the running weight total goes above that value (this gives me a weighted median)

Weighted Median.PNG

I've tries using combinations of FirstSortedValue and AGGR functions but can't get this to work.

Thanks
Matt

Gysbert_Wassenaar

You have an expression that calculates the values in the Above threshold column. You can use that in an expression to highlight the cell using the above() function. Something like:

=if(  above(...above_threshold_expression...)=0 and ...above_threshold_expression...=1  , yellow())


talk is cheap, supply exceeds demand
mjamesking
Creator
Creator
Author

Thanks Gysbert, this works nicely.