REad Data row in Excel and count

Hello Team,
Im trying to get the count of P,A,H,Please guide
image

@Mayyur you can read the excel data sheet into using Read Range which will output a DataTable for you. Then you can use For Each Row activity to traverse thru DataTable and create a local variable counter/counters to increment every time you find an occurrence say. row(ā€˜col1’) equals ā€˜P’ counter_P ++ else row(ā€˜col’) equals ā€˜H’ counter_H++.

Additionally, you might also consider using DataRow variable for each Row being traversed to check each element of DataRow for values P/A/H!!

Try the logic around and share your workflow, if stuck!!

1 Like

I have around 30 columns,

i’m trying to calculate count for each name and for every P,H,A related to name

Seems like attendance data !! Anyways, I would say - ā€œconsider using DataRow[] variable for each row item being traversed and check with nested-if (guess 2 with be fine) element of DataRow for values P/A/H!!ā€ You would need to add another ā€œFor Eachā€ activity for to traverse thru DataRow.

1 Like

Can you please share a workflow similar to it for reference

1 Like

Here you go with a xaml
COUNT.zip (8.3 KB)

CHeers @Mayyur

image ,
Which activity it is…Thanks

2 Likes

its just a FOR EACH LOOP
image

with expression like this
same for all three but with different characters
int_PCount + row.ItemArray.ToList().AsEnumerable().Where(Function(a) a.ToString.Contains(ā€œPā€)).Count

CHeers @Mayyur

1 Like

Yeah its working,but it is adding all P in both the rows,I want to separately count for each name…Thank u

GOt it…Thank you

Cheers @Mayyur

Thanks alot Palaniyappan…for being all time mentor as an when required…

1 Like

@Palaniyappan expression you came up with is bang on :100: !! " int_PCount + row.ItemArray.ToList().AsEnumerable().Where(Function(a) a.ToString.Contains(ā€œPā€)).Count"

1 Like

Hey,Is there any other method of doing the same

This is more reliable and faster
Another method is using loop which might take more time
That’s why suggested this buddy
And by the way kindly mark the right comment as solution that would help others looking for ideas under your topic

Cheers @Mayyur

Sure bro,Im trying to do this with For each loop,getting error…

May I know the error you are facing
@Mayyur

Error- System.Data.Datarow to System.Collection.Ienumerable
image

I want to perform same processing using loops…like the above