Divide value if present

Hi,

i tried to divide the value by 100000. if cell is empty write “0”. On th Base of Columns Name…

n No. of Rows and Columns…

Sample Data.

Input Execpted Output
0 0
641479.6 6.414796
0
85008.72 0.8500872
0
263993.4 2.639934
66790.84 0.6679084
0
97522.41 0.9752241
161216.28 1.6121628
0
102947.2 1.029472
0
90581.56 0.9058156

Thanks
Shyam

You can read the value using Read range activity. Loop through each row and get the values from column “Input”. First use a if condition and check Cint(CurrentRow(0))>0. If greater than zero then you need to divided by 100000 and use write cell to write the value. Else write cell as Zero.

Hi,

Once you have your input as a data table, add a new data column (Expected Output)

Then use a for each row to loop through, as you have mentioned you can check if it = 0 then set the expected output to 0 OR check if its empty or null (String.IsNullOrWhiteSpace(CurrentRow.Item(input))

ELSE
divide by 100000

Hi.

Share the flow in Linq Code… lots of rows and columns…

Thanks
Shyam

Hi Shyam,

sample datatable

Value

1234

4214


3195

you can try this Linq

From d In dt.AsEnumerable _ 
Select If(String.IsNullOrEmpty(d.Field(Of String)("Value")), 0, CInt(d("Value"))/100000)

Thanks,
Saurabh

Hi @saurabh_lawange

Without lose of the columns Data … is it update the data on same datatable.

Thanks
Shyam

Hi @Shyam_Pragash ,

It is not touching the original datatable. Just takes the value, perform the operation and return new value be it 0 or the value after divinding with 100000
It returns new RowCollection(of Double)

Hi @saurabh_lawange

Thanks :slight_smile:

1 Like

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