Hi all i have a data table with the column Price, i need to remove the $ sign in front of all the prices and find the max price how would i do this? Thank you
HI @Pat_Wu
- Use Read Range Workbook to read the excel.
- Use a
For Each Row in DataTableactivity to iterate through each row in your DataTable. - Inside the loop, use an
Assignactivity to update the value in the “Price” column. You can use theReplacefunction to remove the dollar sign.
CurrentRow("Price") = CurrentRow("Price").ToString().Replace("$", "")
- Inside the loop, use another
Assignactivity to convert Prices to Numbers:
CurrentRow("Price") = Convert.ToDouble(CurrentRow("Price").ToString())
- Use the below syntax in Assign activity outside the loop.
maxPrice= dataTable.AsEnumerable().Max(Function(row) Convert.ToDouble(row("Price")))
DataType iof maxPrice is System.Double.
Hope it helps!!
Hi @Pat_Wu
For Each row In dt.Rows
row("Price") = row("Price").ToString().Replace("$", "")
Next
maxPrice As Double = dt.AsEnumerable().Max(Function(row) CDbl(row("Price")))
Hope it helps!!
Hi you can try following
Max_Value = dt_Output.AsEnumerable().Max(Function(a) Convert.ToDouble(a(“Price”).ToString.Replace(“$”,“”)))
Max_Value is a variable type of System. Double
Max_Value = dt_Output.AsEnumerable().Max(Function(a) Convert.ToDouble(a(“Price”).ToString.Replace(“$”,“”)))