I am having a Doubt
i am reading excel file…
With for each activity i am looping through each cell of column “Name” and “Salary”
i want a Flow that if name repeating>1… then sum of the same name salary.
Can you share us a sample input and expected output
Assuming the input like below to be yours. I have done the flow:
→ Read Range Workbook
Output: dt_Input
→ Use Below syntax in Assign:
dt_Output = (From row In dt_Input.AsEnumerable()
Group row By Name = row.Field(Of String)("Name") Into Group
Let TotalSalary = Group.Sum(Function(x) Convert.ToDouble(x("Salary")))
Select dt_Input.Clone().Rows.Add(Name, TotalSalary)).CopyToDataTable()
dt_Output is of DataType System.Data.DataTable
→ Write Range Workbook dt_Output
.
BlankProcess17.zip (46.8 KB)
Input
Sheet is Input and Output
sheet is Output.
Regards
(From row In yourDataTableVar.AsEnumerable()
Group row By key = New With {Key .Name = row.Field(Of String)("Name")} Into Group
Let sumSalary = Group.Sum(Function(r) Convert.ToDouble(r.Field(Of Double)("Salary")))
Select yourDataTableVar.Clone().Rows.Add(Group.First().ItemArray.Take(Group.First().ItemArray.Length - 1).Concat({sumSalary}).ToArray())).CopyToDataTable()
Sequence6.zip (1.8 KB)
Input:
Output:
Follow the below approch.
Assign activity:
nameSalaries = New Dictionary(Of String, Double)
For Each Row activity (ForEachRow in dt):
If activity:
Condition: nameSalaries.ContainsKey(row("Name").ToString())
Then:
Assign activity:
nameSalaries(row("Name").ToString()) += CDbl(row("Salary").ToString())
Else:
Assign activity:
nameSalaries(row("Name").ToString()) = CDbl(row("Salary").ToString())
For Each activity (item in nameSalaries):
Log Message activity:
Text: "Name: " + item.Key + ", Total Salary: " + item.Value.ToString()
Hope it helps!!
@pravallikapaluri
could you please let me know activity from scratch and what would be data tpe of
“nameSalaries”
nameSalaries is of Dictionary Type
In the variables Panel,Go to Browse for types and type
what would be data type… for this
nameSalaries(row(“Name”).ToString()) += CDbl(row(“Salary”).ToString())
Use Assign activity
No need to any data type it is to save automatically in the current row of salary.
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.