Adding coloumns

hi
I want to add coloums A and B in excel which as same row num. I mean in the test data we have loc coloum which has same number . i want the addition of A and B for the loc. i shud get results like for 1 its 7, for 2 its 5 , for 3 its 8… pls refer the test data below. there are 3 coloms loc , A, and B i want addition of A+B
loc A B
1 2 0
1 1 2
1 2 0
2 1 2
2 2 0
3 1 2
3 2 0
3 1 2

Hi @vinutha1
-Please Refer the following workflow it will help you how to add values.AddValues.zip (7.6 KB)

thank u @jitendra_123…il try

@vinutha1 Weclome :slightly_smiling_face:

addition is working da…but i need according to location i mean in my test data i have loc row number same na…so coloumn loc corresponding A+B coloum i want to add.

meanwhile thank you so much for the response

i want the below results…for all loc 1’s its 7
for 2’s its 19 …like wise

Hi @vinutha1

  1. for this you need to use Group by in linq query, —> to make groups with clomun loc

this will hold all sums according to loc in ListA —> List of String

  1. so by using for each you can iterate through that list and use that sum value as per your requirement.

I’m attaching my workflow on your sample data as you’ve mentioned in your topic, for your better understanding.

GroupByDT1.xaml (8.9 KB)
:slight_smile:

Try this and for a better approach use LINQ

AddValuesBasedOnColumn.xaml (12.5 KB)

Thank you so much @samir…pls let me knw how to build data table from excel sheet as the values will be changing dynamically

thank you @sankar.kuna.

hey @vinutha1 In your case you need to use Read Range activity in Excel application scope
and don’t forget to create output variable for Read Range activity (Here —> dta)


I’ve used build dataTable activity to explain you with sample data.

hey @samir…thank you so much da…got the results. it was soo helpfull!!

Welcome
:blush: Cheers.

hey @samir… i have a website in which a data table is extracted from which i have to get the input to achive the same results … as i explained u yesterday. pls let me know how to achieve this. Datatable is ready…i just want to add from it…pls suggest me how t do this

hi @vinutha1

okay, you just need to pass Output variable of your Extract Structured Data activity (the activity you’ve got whem you used data scraping wizard) to query.

So, pass that dataTable variable (suppose it is DT) in query, —> instead of dta in query
so your query should be like,

(From p In DT.Select()
Group p By id=p.Item(“loc”).ToString Into GroupA=Group
Select Convert.ToString((GroupA.Sum(Function(x) Convert.ToDouble(x.Item(“A”).ToString)))+(GroupA.Sum(Function(x) Convert.ToDouble(x.Item(“B”).ToString))))).ToList()

thank you @samir

Hi all
image

Above is the sample data given. In this i want to group all the class codes and amount of each location
eg: for loc 1, there are 3 class codes and 3 amount it has to loop one after the other
for loc 2, there are 2 class codes and 2 amounts it has to loop one after the other
like wise for all the location it has to loop. (The data table is already ready)

Guys help me in solving this . Any advice and suggestions are welcome …thanks in advance!!

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