How to find maximum number from a range

waziaks

Member
Hi there,

Is there a way to find maximum number from a range. I've used "Get workbook to collection" now all the data is appearing into collection. But I need to find the maximum number from collection. Screenshot attached for reference.
 

Attachments

  • collection.JPG
    31.7 KB · Views: 43

sivagelli

Well-Known Member
Use Sort Collection Action from Collection Manipulations VBO. Pass inputs of Collection Name, Field Name and for Ascending Order pass False.
This will get you a sorted collection in descending order.
Now to get the first value of the collection, you have to use loop stage and get the value in to a data item.

Loop Start
Use a Decision stage
For Yes, have a calc stage with expression, [CollectionName.Fieldname] and store in to a data item. Then ,link this to End​
For No, Link to the Loop End.​

You will get in to the loop just to read the value from collection and End the loop.
 

VJR

Well-Known Member
Hi there,

Is there a way to find maximum number from a range. I've used "Get workbook to collection" now all the data is appearing into collection. But I need to find the maximum number from collection. Screenshot attached for reference.
Hi waziaks,

Since you already have the data in excel you can get the maximum value there itself.

-In any blank cell, use 'Set Cell Value' action and insert the formula as "=MAX(A1:A9)"
View attachment 1542965586365.png

Using 'Get Number of rows' action you can also use a dynamic formula if you are unaware of the last row.

-Then use 'Get Cell Value' to read the result.
-Once done you can clear the formula cell using 'Set Cell Value' with an empty string "".

After seeing your data in a collection I wanted to suggest you to sort the collection to get the maximum value but the screenshot shows that the values are of Text datatype. This might cause issues after sorting in cases like 1, 10 which becomes a Text based sorting.
 

waziaks

Member
sivagelli, I am able to apply your method and got the desire output thanks for you help. VJR, I am also able to get my desire output by using your method as well. However, when I am trying to dynamic the formula using "Get number of rows" it's not giving me the desire output maybe "get number of rows" in number data type and I am calling it in a text data type. Any thought on this?

I've attached the snapshots for reference
 

Attachments

  • SC1.PNG
    18.4 KB · Views: 28
  • SC2.PNG
    16.2 KB · Views: 25

VJR

Well-Known Member
when I am trying to dynamic the formula using "Get number of rows" it's not giving me the desire output maybe "get number of rows" in number data type and I am calling it in a text data type.
If LastRow is a data item use an expression such as "=MAX(A1:A" & [LastRow] & ")"
 

waziaks

Member
I've tried the above way but it's not working. Attached are the screenshots for the reference
 

Attachments

  • SC1.PNG
    15 KB · Views: 22
  • SC2.PNG
    16 KB · Views: 15

VJR

Well-Known Member
In case you want to use a direct Data Item then use a Calc stage with the above formulated expression and then set its output to a Data Item and then pass the resulting Data Item in the Value parameter of Set Cell Value.
 
Top