This program is working fine. It is from Excel and Data Table, Practice 1, Calculating Sums part 3. I am not understanding one thing here that if we set A1 and B1 static over here. At first it seems to me that same values will be printed in front of every row but the case is opposite. Its functionality is unfathomable to me.
Main.xaml (7.6 KB)Hello @nashrahkhan!
It seems that you have trouble getting an answer to your question in the first 24 hours.
Let us give you a few hints and helpful links.
First, make sure you browsed through our Forum FAQ Beginner’s Guide. It will teach you what should be included in your topic.
You can check out some of our resources directly, see below:
-
Always search first. It is the best way to quickly find your answer. Check out the icon for that.
Clicking the options button will let you set more specific topic search filters, i.e. only the ones with a solution. -
Topic that contains most common solutions with example project files can be found here.
-
Read our official documentation where you can find a lot of information and instructions about each of our products:
-
Watch the videos on our official YouTube channel for more visual tutorials.
-
Meet us and our users on our Community Slack and ask your question there.
Hopefully this will let you easily find the solution/information you need. Once you have it, we would be happy if you could share your findings here and mark it as a solution. This will help other users find it in the future.
Thank you for helping us build our UiPath Community!
Cheers from your friendly
Forum_Staff
Hi @nashrahkhan,
We need better perspective to help you. Could you show us whole xaml? Isn’t there any for each statement or any variable used?
Ok I took a closer look on it. So this is working like it should and you see different result for each run because (I assume that earch row have different values in columns A and B - I don’t have access to example file) each time loop is running it takes one-by-one next rows. So the first run will sum A1 and B1, then A2 and B2, then A3 and B3 and so on.
Yes @Pablito, you are right its working same as you told.
but my question here is this that how it is giving different results for every row in “C” column becuase we have just used the static formula =SUM (A1+B1).
Even if we have to use same formula in excel, it will increment the rows like for C2=SUM(A2+B2), FOR C3=SUM(A3+B3) and so on.
I’m still not sure if I understand the question right. The Screenshot of results in file could be helpful here. But let me describe the process. Maybe this will help you to understand.
- We’re taking excel file and it’s “Sheet1” and giving the output as “inputdata” to
For Each Row
activity.
- For each row activity is going one-by-one through row after row on each iteration. (this means that first run will take care about first row, second about second row… and so on.
- For each row and every iteration inside the loop we have RowCount variable to which there is actual number of rows attached. (
inputdata.Rows.Count
). I’m not sure why this is here as it will return exact same number on each iteration as inputdata is having exact same number of rows no matter what.
- At the end we are writing data to excel sheet to
"C1:C" + RowCount
. As I said above RowCount will have exact same numbers of rows as it’s depended on inputadata which will not change. This means that on each iteration you are trying to push SUM of A1 and B1 to exact same place which will be C1:CX (where x is number of rows.).
And I guess you problem is that you have same results on each row. And this is caused by you RowCount which will not change. To achieve calculation for each row separately like you did directly in excel, you need to use indexes or (easier way) counter. Something like this: