How to remove decimal from a value

Hi,
I have a sheet in which there are decimal values I just have to remove the decimal values and convert it into simple integer value without decimal.
Ex:- If a value is 40.00 I want it in 40 format.
Here is the attached excel for the same.
NumberSheet.xlsx (15.9 KB)
Thanks in advance!!

@Kunal_Jain

hi for the some of the values there are

250.83 you want 251 or 250
579.77 you want 580 or 579

can you please explain what you want

Hi @Shiva_Nikhil
Just remove decimal.
If 279.99 will be converted to 279
Cheers

Hi, you can use below expression

Convert.ToInt32(40.00)

Hi @neha.upase
Cant we use an invoke code activity because it has to be a data table.
Cheers

Hi @Kunal_Jain

How about the following?

O/P:

NumberSheet.xlsx (15.9 KB)

Hope this helps!!

Hi @lrtetala
Why Custom??
We have to convert all the columns decimal values but there are some string columns also
Which I have not provided?

@Kunal_Jain

refer this

For Each row As datarow In dt1.AsEnumerable
row(0)=row(0).ToString.split(“.”).First
row(1)=row(1).ToString.split(“.”).First
row(2)=row(2).ToString.Split(“.”).First
row(3)=row(3).ToString.Split(“.”).First
Next

Sequence.xaml (7.4 KB)

@Kunal_Jain

Then give respective columns like this

image

Hi @Kunal_Jain

Try this:

newDT = (From row In dt.AsEnumerable() Select dt = New Object() {
                              Integer.Parse(row(0).ToString), 
                              Integer.Parse(row(1).ToString),
                              row(2).ToString, 
                              Integer.Parse(row(3).ToString), 
                              Integer.Parse(row(4).ToString),
                              row(5).ToString}).CopyToDataTable

For example, Here column indexes 2,5 are string columns so they didn’t need to change.

You can simply use Cint(yourvalue)
Ex: Cint(“40.00”)

Regards,
Namrata

Why you are using invoke code.

You can use Cint(Your Value)
or
You can use format cell activity

@Kunal_Jain

you can also try this way

use assign activity

dt=(From r In dt.AsEnumerable
Let a = r.ItemArray.Select(Function(b) If(b.Tostring.Contains(“.”),b.ToString.Split("."c)(0),b.ToString)).Toarray
Select r1=dt.Clone.Rows.Add(a)).copytodatatable

Sequence.xaml (7.7 KB)

grafik
vs.
grafik
where no rounding is triggered

Hi @copy_writes
I am using the mentioned code
Try
dt.AsEnumerable().ToList().ForEach(
Sub(row)
row.SetField(“decima”, String.Format(“{0:0}”, Convert.ToDouble(row(“decima”).ToString)))
row.SetField(“decima2”, String.Format(“{0:0}”, Convert.ToDouble(row(“decima2”).ToString)))
End Sub
)
Catch exp As Exception
Console.WriteLine(exp.Message.ToString)
End Try

Can you just let me know what change I need to do in this?
Cheers

Hi @Shiva_Nikhil
The document you shared is invalid.
Can you share the zip file please?

@Kunal_Jain

splitingvalues.zip (2.7 KB)