I am using a For Each data table and using the assign activity where i am adding the data as per the condition in the end i have the variable called “lv_new” in which i am getting the data the loop will going to repeat as many times and we will get the value of lv_new but i don’t know how to sort that data and find out out the largest among them?
Hey , In lv_new
Hey @anurita.mishra
Sorry, It’s a bit unclear.
Actually I’m not getting what do you want to sort here please… ?
As integer variable is a constant Sum. Kindly explain.
Thanks
#nK
Hey , @Nithinkrishna
I have a secenrio in which i have to sum the values corresponding to their ,material where materials are not fixed so i used a For Each Data where i am adding the weights of the materials and in the end. Suppose in the end i have the weights like For ex :- 34,65,78,9
Now i have to find out the Largest Among them.
Thanks,
Hey @anurita.mishra
Cool, It’s clear now. Thank you for explaining.
Just have these in a List(Of integer)
and let’s assume lv_new
as integer list with weights
lv_new.Sort().Last
The above statement will help you get the largest.
Hope this helps
Thanks
#nK
@anurita.mishra Just some additional info,
Creating & initialising a list from variables panel
List(Of Integer) lv_new = new List(Of Integer)
To add the weight on every iteration
lv_new.Add(weight)
Also, Add to collection
activity can be used as an alternative for the above.
Thanks
#nK
Okay @anurita.mishra
You are getting some list of weights from the foreach iteration and from that you want to find the largest weight after the end of iteration…
Is this right,.please ?
Thanks
#nK
Yes I am getting the list of weight
lv_new(of type int) = lv_new + CInt(dt_final.Rows(0)(“Weight”))
like this
but in lv_new each time the weight will be add and the previous one will be removed so first i have to store all the weight sums then i have to find out the largest among them hope its clear.
Hey @anurita.mishra
You are on the right path…
And the Add
which I mentioned is not sum or I’m not sure you are adding it for a different purpose.
You need to now please create a new integer list variable & keep on adding the weights to it on every iteration ( you can use Add to collection
activity for adding)
After you add and the iteration completes, Just do the sorting mentioned above & you will get the largest of all the weights.
Hope this helps
Thanks
#nK
Hey @anurita.mishra
You can also share workflow file if possible. So that I can provide you the flow.
Thanks
#nK
use this:
here x is the input string,
x.OrderByDescending( Function(x) x)
output : { ‘9’, ‘9’, ‘7’, ‘6’, ‘6’, ‘5’, ‘5’, ‘3’, ‘3’, ‘2’, ‘2’, ‘2’ }
dt.AsEnumerable().Max(Function(row) row(“rownametosort”))
You can use above linkq and get the max value, replace rownametosort with your DataTable column name.
Yes please say ?
Thanks
#nK