How to count the number of leaves, weekends and holidays in a month from an employee timesheet using switch activity based on the bot running month. Leaves is mentioned as “L”, weekend is mentioned as “W”, holidays is mentoned as “H” and working days is mentioned as interger (0-10)
I am not really sure about the data structure whether you are reading from excel or scrapping it from a webpage.
But using switch statement you can set the datatype as String & add three cases with “W”, “L”, “H” and then in each case blocks, we can add increment counter.
Like for “W”, we can have Weekend_Count = Weekend_Count + 1,
for “L”, we can have Leave_Count = Leave_Count + 1.
Hope this helps.
As you mentioned employee timesheet, is it a web page or any other tool you are using.
Based on the excel.
If possible could you please share the screenshot of the workflow that you have done so far. May be it would give us better clarity of the issue & we will be ready to help you out.
Try with this linq query using Assign activity “intWeekendCount” is the first integer variable to hold Weekend Values, this will give you the weekend count from your required column, you can get other values similarly
yourDataTable.AsEnumerable().Count(Function(row) row.Field(Of String)("ColumnLeave") = "W")
Thank you… I got it.
Could you please mark the right answer & close it.
Or you can write your answer here so it could help someone else too.
1.Drag and drop an if condition inside it expression (counteddays<DaysInmonth) Assign counteddays as zero and DaysInMonth as DateTime.DaysInMonth(DateTime.Now.Year,DateTime.Now.Month).
2.Pass switch activity inside the if condition.
3.Inside switch provide value as - row(col.Tostring).Tostring (this is to read the excel cell columnwise-horizontally).
mention default as Workingdays=workingdays+1
Case W ,assign it as weekends =weekends+1.
Case L ,assign it as Leavecount=leavecount+1.
Case H ,assign it as HolidayCount =holidaycount+1.
then outside the switch drag and drop another assign activity and assign countedday=countedday+1.