How to calculate a particular datacolumn sum using datatable or structured format?


I wan to read all the Amount which is in + and - number and calculate sum of the amount , can you help me how to solve it efficiently.

HI @Vidhi_Patel

How about this expression

(From d in dtData.AsEnumerable Where Not (isNothing(d(2)) OrElse String.IsNullorEmpty(d(2).toString.Trim)) Select v = CDbl(d(2).toString.Trim)).Sum(Function (x) x)

Regards
Gokul

1 Like

Hi @Vidhi_Patel,
DT.AsEnumerable.Sum(Function(a)Convert.ToDouble(a(“Amount”).ToString))

1 Like

Check out this XAML file

SumUsingLINQ.xaml (7.6 KB)

image

Regards
Gokul

1 Like

Thank you a lot @Gokul001 It’s works but i don’t understand LINQ query , will understand it later ! :slight_smile:

1 Like

Hi @Vidhi_Patel

You can try with this expression

DT.AsEnumerable.Where(Function(s) Not String.IsNullOrEmpty(s("Column1").ToString)).Sum(Function(a) Convert.ToDouble(a("Column1").ToString))

Regards
Sudharsan

1 Like

My Data has a unnecessary row 2 , how to remove it?! I’m using generate datatable activity to convert scrapped data to datatable. Here, is my scrapped data from which i want to extract Amount from.

transactionID transaction Date Amount Type
Line up Position Page down Line down
56698975 20-04-2017 00:00:00 -26937 Online
37094339 12-05-2017 00:00:00 224765 Online
21463277 11-04-2017 00:00:00 -245840 Offline
51150782 29-01-2017 00:00:00 173566 Online
97780992 25-03-2017 00:00:00 -276276 Online
87387732 13-01-2017 00:00:00 -126520 Online
70401268 06-09-2017 00:00:00 116441 Online
98768414 18-08-2017 00:00:00 150070 Online
33407473 13-02-2017 00:00:00 192071 Online
95746337 01-04-2017 00:00:00 198716 Online
78511742 23-05-2017 00:00:00 -292681 Online
45980947 30-05-2017 00:00:00 83804 Online
85228152 24-07-2017 00:00:00 75230 Online
88047654 27-06-2017 00:00:00 89967 Offline
67493785 07-06-2017 00:00:00 136473 Offline
25750190 04-03-2017 00:00:00 47488 Online
61880498 25-03-2017 00:00:00 262895 Online
87262253 14-01-2017 00:00:00 103066 Online
78118635 26-04-2017 00:00:00 -124403 Online
77738358 10-01-2017 00:00:00 287511 Online
82858659 17-08-2017 00:00:00 -265325 Online
69980765 24-04-2017 00:00:00 11761 Online
91528635 27-08-2017 00:00:00 -82321 Offline
18908192 12-02-2017 00:00:00 -113450 Offline
57810392 01-06-2017 00:00:00 180636 Online
52831866 29-07-2017 00:00:00 -277526 Online
52503843 02-08-2017 00:00:00 144453 Online
64160749 12-03-2017 00:00:00 30015 Online
37425592 24-05-2017 00:00:00 59621 Online
88153940 20-04-2017 00:00:00 252309 Online
37780506 24-06-2017 00:00:00 47840 Online
65128239 10-09-2017 00:00:00 172057 Offline
23799793 29-08-2017 00:00:00 -280620 Online
54628800 20-01-2017 00:00:00 86182 Online
52932654 27-01-2017 00:00:00 -186498 Offline
85041057 10-03-2017 00:00:00 -122467 Offline
27857903 01-02-2017 00:00:00 -179025 Offline
68816013 20-01-2017 00:00:00 -215378 Online
81130056 13-02-2017 00:00:00 281822 Online
21357694 16-03-2017 00:00:00 -12244 Online
57538278 19-04-2017 00:00:00 247189 Online
11213484 05-07-2017 00:00:00 208188 Offline
34375388 12-08-2017 00:00:00 117275 Online
60817491 28-02-2017 00:00:00 -169018 Online
83779075 18-04-2017 00:00:00 -172136 Online
29729807 06-05-2017 00:00:00 43197 Online
38099243 30-04-2017 00:00:00 255653 Offline
69046738 10-07-2017 00:00:00 -205416 Online
40122795 19-05-2017 00:00:00 -95742 Online
46707781 24-08-2017 00:00:00 -189646 Online

How to determine the row is unnecessary?

For this issue can you create a new topic @Vidhi_Patel , So that user many not get confuses

@sangeethaneelavannan1 User can create the new topic

It has text like this

Line up Position Page down Line down

which was due my scrapping method i guess !

@Vidhi_Patel
Use Remove data row activity
Please create new topic for the issue.
image

1 Like

@Vidhi_Patel
Only reply here if:

  • You have additional details
  • The solution doesn’t work for you

If you have an unrelated issue, please start a new topic instead.

1 Like

I have Related Isuues , can proceed with this thread…

Your Issue is to sum the Amount column Right? @Vidhi_Patel

That has been solved i think so. Then what is the Issue you are facing?

1 Like

You can see my data in above reply , i’m not able to get proper format of datatable from Scrapped text while using generate datatable from text activity , i’m not getting that how i can i apply solution query!

Hi @Vidhi_Patel

You Query is to Sum the Amount column Right? It has been done.

So for this, you can create new topic

1 Like

okay , Thank you! @Gokul001

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