Compare double and set it as minimum

I am having trouble now where I am trying to compare between two double variables from datatable. Assuming I have initial value as 1.2 and I set it as minimum and the value from datatable (double datatype) is 1.0,1.4,0.3.

minimum = 1.2, when compare the first value with minimum, it should be the new minimum = 1.0. However I am having problem where it can compare and print the new minimum but it does not replace the new minimum value


Hope the below steps would help you resolve this

  1. Use a excel application scope and pass the file path as input and inside the scope use a read range activity and get the output as datatable dt

  2. Let’s take like you have a string variable named minimum which is equal to “1.2” and now let’s create a new column in that datatable dt to mention the new minimum value

  3. Use add data column activity where mention the column name as “Result” and datatable as dt

  4. Now use a FOR EACH ROW activity and pass dt as input

  5. Inside the loop use a IF condition like this

Convert.ToDouble(minimum.ToString) > Convert.ToDouble(CurrentRow(“yourcolumnname”).ToString)

If true it will go to THEN block where you can use a assign activity like this

CurrentRow(“Result”) = CurrentRow(“yourcolumnname”).ToString

If fals it goes to ELSE block where we need to write the minimum value itself
As it is not less than 1.2

in else block use a assign activity like this

CurrentRow(“Result”) = “1.2”

Cheers @aqiff

As an alternate use the min() function within a single Assign acitvity:
myMin = dtData.AsEnumerable(Function (x) CDbl(x(YourColNameOrIndex).toString.Trim))

1 Like

@ppr @Palaniyappan thanks i will try both of ur solution. Can u also help me on this ? I have been stucked on this for so long. Arrange data from other datatable based on minutes variance. Thanks

done on other topic by demonstrating an aproach along with helper XAML

To be honest, im amazed by your method of solving this problem. I wish i could be at your level of knowledge, can I know the methods used in the solution ?

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.