 Hey guys, welcome to SSUniTech, so we'll decide and today we are going to see about the switch activity. So what is the switch activity and where we can use that. The switch activity provides the same functionality that switch statement provides in programming languages. Like if you have knowledge on the SQL server, then you can relate this with the switch function or the case statement. It evaluates a set of activities corresponding to the case that matches the condition evaluation. For example, we are having one blob storage and blob storage is having different set of files like few files which are related to the employee data, few files which are related to the payroll data, few files which is related to the item data. And we want to load these different set of files into SQL server tables. So how we can load all these. So for that either we can use the filter activity to do the filter for the employee payroll and item in different sets or we can use the switch statement by single switch statement can do the same functionality. What is the use case of the switch activity. So if condition can have only one condition that I told you in the if condition if we are going to use then it will be going to check the condition whether that is true or false. We cannot specify more than one condition there. So it will be having only one condition but switch can have more than one condition. So now go to on the browser and we'll try to understand the requirement and then we'll try to implement this in practical. So here we are having this blob storage and under this blob storage we are having employee data like employee India, employee US and employee TXT. So these three set of files which is related to the employee data. Next we can see the item. So it is related to the item data. Then we are having these two as payroll data. So we want to load these by using a single switch statement. So how we can do that. So before going to implement this if you haven't watched the get metadata activity and the forage activity. So I would strongly recommend to watch these two videos because we are going to use these two activities here. I'll provide the link of those videos in the description of this video. So go to on the azotata factory and here let me try to add a new pipeline and let me call this pipeline as switch activity. Now here first we are required to use the get metadata activity. So it will be going to get all those files. So under the get metadata activity as we have already seen in the previous video in detail about the get metadata activity. So go to the setting directly and here we need to specify the dataset. We have already created the dataset. So we can use this dataset. Let me show you the dataset. Click on open. Here the link service we can edit. So this link service is indicating SSU testing account. So if you can go here, so this is the SSU testing. Now here we can see the input folder. So under the input folder that we are so we are having these files. So this is the dataset and if we are going to debug this so here it cannot be empty. So what we need to do here we need to add the field list. So we want to see the child item for these because the child item will be the files. Now let me try to debug it. Here we can see the output. So under the child items we can see the employee dot ext, employee india, employee us, then item, then pay india, pay us. So all these files are there. Now we can use the for each activity. So for each activity we will be going to loop through with all these files. So let me connect with the get metadata and under the for each activity go to the settings and here we can see the items. So under the item what we need to do we need to select this get metadata activity with the child items. So that is it. We can click on ok. So that will be the input of the for each activity. It will be going to loop through with all the files. Now go to under the activities and here we need to use the switch activity. So under the switch activity we can directly go under the activities. First is the expression. So here under the expression we are required to specify the expressions. As we have already seen the output so those are like the complete file names. But we want to split the file names as per their starting three characters. If that is EMP then that will be the employee file. If that is the pay then that will be the payroll file and by default that will be the item file because we are having only these three set of files here. So we have to use the substring function here and here we need to specify the starting. So we are required to get it from for each item. Then we need to start with a zero and we want to get the three letters. So this is we need to specify under the switch activity. Let me click on ok. Now here we need to add the case. So in the first case if your expression value is EMP then we want to execute the copied activity for the employee tables. Second if this is the pay then we want to execute for the payroll and the last one is the by default that will be the item. So let me quickly go here on this pencil icon and here we can use the copyright activity. So instead of loading the data I am going to use the wait activity here. So it will be going to save the time because we have already discussed about the copyright activity multiple times. So this will be the payroll. So we can call this as payroll. Let me go back to here. Next will be the employee. So we can add the wait one as employee and go back to the for each and here by default that will be the item. Now if we are going to execute this then what will be happening? In this case three times we can see this employee India, employee US and employee. So these three times employee file will be processed one time item and two time payroll one. Let me try to debug and we will see in the practical. So now it is executing. So get metadata executed successfully. So this got filled. Let me check the error. So error in the switch statement and it is saying the function substring expect the first parameter string. So let me go here and in the switch statement go to the expression. So under this we have not specified the name here because it is an object type and if we are going to specify the name then that will be one by one. It will be processed. Now let me click on and try to debug it again. So that has been started again. So everything is completed. So we can go here and let me start with the get metadata activity and we will try to understand one by one. So here we can see the child items. So all these files are here. Now we can go in the for each. So under the for each we can see total six items. So the total six files is there. Now in the switch case if we can see here so it is for the item as we can see the three letters from there. Now if you can go the second one then that will be the payroll. So two times for the payroll so EMP three times. So that is in the switch case. Now here in the wait activity we can see three times employee file has been processed one time item and two times payroll file has been processed. So this is the same thing that it is doing. So obviously we have seen in the filter activity we have filtered the data directly without using the switch case. So we had to use the three filter activities one for the employee second for the payroll and third for the item. But after using the switch activity directly we can use the switch activity and we can add whatever the set of files there we can directly add the case one by one as we have added here. Like we have added two case we can add more cases if your set of files like those. So this is all about the switch activity. So thank you so much for watching this video. If you have any doubt then you can drop your questions in the comment box. I will try to response there. Thank you so much again. See you in the next video.