Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I have load script that load data from database. I need to get new column for table that has value based on following condition.As an example in attach image, for the row that with PRIORITY_CATEGORY 33 I need to get new column that has sum of qty_remaining below the value of PRIORITY_CATEGORY. for PRIORITY_CATEGORY 33 i need to get new column with value 0.00048
@layanmahendra try below expression
=sum(aggr(rangesum(above(total sum(QTY),1,RowNo())), RPART, (PRIORITY_CAT,(NUMERIC,ASCENDING))))
LOAD *
Inline [
RPART,QTY, PRIORITY_CAT
A,10,10
A,15,5
A,20,10
A,5,33
A,3,4
B,10,7
B,5,6
B,5,5
]
;
@layanmahendra Is this logic required only for category 33? I can see there is another category with required value but what if there more than one category ? which value need to pick?
Yes there are
I think this attachment in more details what i need to be figure
@layanmahendra try below expression
=sum(aggr(rangesum(above(total sum(QTY),1,RowNo())), RPART, (PRIORITY_CAT,(NUMERIC,ASCENDING))))
LOAD *
Inline [
RPART,QTY, PRIORITY_CAT
A,10,10
A,15,5
A,20,10
A,5,33
A,3,4
B,10,7
B,5,6
B,5,5
]
;
Thank you this is do the work. But I need to do it for combined with another column YEAR. like this,
LOAD *
Inline [
RPART,QTY, PRIORITY_CAT,YEAR
A,10,10,2022
A,15,5,2023
A,20,10,2023
A,5,33,2022
A,3,4,2022
]
output should be
RPART QTY PRIORITY_CAT YEAR RESULT_QTY
A 10 10 2022 3
A 15 5 2023 18
A 20 10 2023 23
A 5 33 2023 48
A 3 4 2022 3
Please how to do such??
Thank you
Thank you and this is working. But now i need to get result based on YEAR as well.
output should be like this