How to get the first occurrence for a word

I have a column (“Status”) that Contains many Status Like: Success, Failed, In Progress, etc…
i want to store Any Word appear “Success”, Failed the Values in a variable so i can use it Later For Counting,
The question is how can each value and store in a variable ?

the output Summary sheet must be like this :
Success / Failed / In Progrress(If Appeared)
389 279 38

i hope i clarify it enough
Thanks in advance

Hi @Karam_Abulawii

you can use add to collection activity to store all the status. these will be stored in a list and you can further manipulate as per your logic

can you Provide an Example of it ?

prepare a datatable with build datatable activity - dtStatistic
Cols: Status, Count

Assign activity:
left side: dtStatistic
right side:

(From d in YourDataTableVar.AsEnumerable
Group d by k=d(“Status”).toString.Trim into grp=Group
Let ra = new Object(){k, grp.Count}
Selet r= dtStatistic.Rows.Add(ra)).CopyToDataTable

it will create for a statistic dynamily on all occuring status values

Also have alook here:


HI @Karam_Abulawii ,

Here is activity called “Find” . It will return the all rows where the find text appear. you can give the cell range as “Y:Y”.


Thanks For the Reply
But i want to add Columns Dynamically Based on the Values of the Columns
when “Success” Appear Then add a column named “Success” and get the Count and so on
i will attach the Workflow if You can help me Do it
Thanks in advance (356.2 KB)


this can be achieved by postprocessing dtStatistic retrieved as described fom above


prepare a datatable with build datatable activity - dtStatistic
Cols: Status, Count

Assign activity:
left side: dtStatistic
right side:

(From d In YourDataTableVar.AsEnumerable
Group d By k=d(“Status”).toString.Trim Into grp=Group
Let ra = New Object(){k, grp.Count}
Select r= dtStatistic.Rows.Add(ra)).CopyToDataTable

Generate dtTarget:

  • Assign activity: dtTarget | DataType: DataTable = new DataTable()

  • For each row activity | row in dtStatistic

    • add DataColumn Actity | Datatable: dtTarget | TableName: row(“Status”).ToString
  • assign activity
    left side: dtTarget
    right side

(From i In Enumerable.Range(0, dtStatistic.Rows.Count)
Let ra = dtStatistic.AsEnumerable.Select(Function (x) x(i)).toArray
Select r = dtTarget.Rows.Add(ra)).CopyToDataTable

@ppr Thanks for Replying
but the 2 assign activities have errors maybe you can check them

I will check soon, just minial issues on brackets, some namings.
Please gie me a a littel time

Respect the line breaks for readabilty in case of we are using LINQ Query Syntax

@ppr Take your time
Thanks for your Time

updated it above and it is validating:


Thank You it’s Validating
but I got Error

kindly Check this out

which assign is failing?
Can you share your XAML?

can you show the part where you are defining the datatable dtStatistic?

we do need to know the details and and get ensured that only the two cols: Status and count are created

In general the issue comes from a missmatch between col structures and the added DataRowArray

Hello @ppr
I Fixed the error And worked As expected
Thanks for your time
Much Appreciation
best Regards.

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