Sum Up per category

Hi Friends,
I have the below Datatable -

image

I want to sum up all the ‘Value’ for each category of Expense, meaning I want -
Vacation - 2000
Savings - 2500
Rent - 7500

How can I achieve this …pls advise.

Thanks

Let’s say your datatable name is dtCashFlow, you just make a “For Each” row of your datatble then inside it have a switch case
row(0).ToString.ToLower.Trim

Case vacation
Assign intVacation = intVacation + cint(row(2).ToString)
Case savings
Assign intSavings = intSavings + cint(row(2).ToString)

and so on for all your cases

@Rani1978
we can use a group by.

find some starter help here:
GroupBy_Sum_1Col.xaml (7.9 KB)

2 Likes

but what if you don’t know the Expense Category, or if there are many such expense categories, you can not declare so many cases, Is there any command which compares the expense category and at the end of that exp category sums up. we have such commands in SAP ABAP but do not know in RPA if there is any such command. I also do not have a VB background.

Please advise.
Thanks

Thanks for the xaml. the workflow works but i have no clue what language is that, is it VB, i do not have VB Background, could you please explain what each line of code in the below screenshot means.

image

Thanks

It is LINQ
https://www.tutorialsteacher.com/linq/linq-tutorials

another option would be a look on this activity:

have a look on the Aggregation Activities

2 Likes

Thanks a lot.

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