How to compute in excel with conditions?

For example I want to get the sum of salary of each person with a senior position.

Name Position Salary
A Junior $123
B Mid $456
C Senior $789
D Senior $789

Hi @acdeleon,

Welcome to our Community!!

You can easily do it. You can add name and amount as in the form of dictionary in uipath. later you can check an condition if key=senior, then you can add salary.

Let me know, if you need workflow for this. I will be happy to assist you!!

Hi @acdeleon

You can try this in simple way

  1. First create an excel file like this

  2. Use read range activity to read the excel file and store in dt1 variable.

  3. now use below assign query

sum= dt1.AsEnumerable().Where(Function(row) row("Position").ToString.Equals("Senior")).Sum(Function(row) CDbl(System.Text.RegularExpressions.Regex.Match(row("Salary").ToString,"[0-9]+").Value))

where sum is displays the sum of salary of persons whose positions is Senior.

The output i got
image

Check this workflow

Main.xaml (6.0 KB)

Find the attached excel file:
input.xlsx (9.2 KB)

Hope it helps you

Regards

Nived N

Happy Automation

1 Like

Hi upon using this syntax the output seems not accurate.

Please check. The yellow highlight is the manual computation
image

I have attached the excel file for your reference.
Daily Transactions.xlsx (219.3 KB)

Hi while try to change the Assign activitiy like this below

sum= dt1.AsEnumerable().Where(Function(row) row("Position").ToString.Equals("Senior")).Sum(Function(row) CDbl(System.Text.RegularExpressions.Regex.Match(row("Salary").ToString,"[0-9.]+").Value))

It will work

Regards

Nived N :robot:

Happy Automation :relaxed::relaxed::relaxed::relaxed:

2 Likes

Thanks! now working

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