UiPath | LINQ IF Condition | IF for Arrays | IF for Data Tables | IF for empty output of LINQ query

  Рет қаралды 7,033

Act Automate

Act Automate

Күн бұрын

Пікірлер: 47
@TheOriginalbeat
@TheOriginalbeat 3 жыл бұрын
The best RPA tutorials on KZbin, a huge thanks to you Mahmoud.
@ActAutomate
@ActAutomate 3 жыл бұрын
Very happy to hear that, thanks Mohamed 🙂
@adarshautomation4995
@adarshautomation4995 3 жыл бұрын
Keep going brother .. it's really helpfull...
@ActAutomate
@ActAutomate 3 жыл бұрын
Thanks Adarsh. Will do
@biswajeetkumar9327
@biswajeetkumar9327 Жыл бұрын
Hi, I have a doubt, In the last example of exception handling using if you have used out_dt.rows.count>0 (initially as the out_dt will have empty rows always) so when will the query gets executed? whenever we will run this will generate an empty datatable! can you help me in this?
@ActAutomate
@ActAutomate Жыл бұрын
Yes you are right. This was only wrong example here without testing! You can also check the other comments to know that. But I implemented the same function in another video (Filter Data Table). Check this video to learn more about this exception how to avoid if you don't have output from the query.
@biswajeetkumar9327
@biswajeetkumar9327 Жыл бұрын
@@ActAutomate ok ok got it! I didn't see the previous comments. Thanks for the Reply :-)
@nass9876
@nass9876 3 жыл бұрын
Very informative, keep explaining and covering complex scenarios too ...your way of teaching it feels like the topic is quite easy ..thank you
@ActAutomate
@ActAutomate 3 жыл бұрын
I am very happy that you liked the video.
@girishkrishna4654
@girishkrishna4654 Жыл бұрын
13:05 line 1: condition should be Excel_DT.Rows.count > 0 right ?!
@ActAutomate
@ActAutomate Жыл бұрын
No the complete query is wrong, sorry for that. I published the correct one in another video. This was a wrong query, what I didn't test before. Please check the example inside this video to learn more about the issue how to handle: kzbin.info/www/bejne/h3jNnYaberugrdU
@VIJAYLNYADAV
@VIJAYLNYADAV 3 жыл бұрын
Thankyou very much for this solution. I was searching for how to resolve the error and thankfully i followed your videos
@ActAutomate
@ActAutomate 3 жыл бұрын
You're welcome :-)
@aparnakrishnan5465
@aparnakrishnan5465 2 жыл бұрын
Thanks a lot 😊. Very informative video.
@ActAutomate
@ActAutomate 2 жыл бұрын
Thanks for the feedback Aparna :-)
@asramaa
@asramaa 2 жыл бұрын
Thank you Mahmoud.
@ActAutomate
@ActAutomate 2 жыл бұрын
Thanks Fasulu :)
@sunnysingh-ng5bz
@sunnysingh-ng5bz 3 жыл бұрын
Thank you Mahmoud 😊
@ActAutomate
@ActAutomate 3 жыл бұрын
You're welcome 🙂
@andizaid616
@andizaid616 2 жыл бұрын
hi . what if i just want to copy a specific row value from dt1 to dt2 ?
@ActAutomate
@ActAutomate 2 жыл бұрын
Hi Leo, You first need two tables, OriginalTable and the new table (Out_DT) where you want to copy the row. Then you need an Assign activity to clone the tables. Set the following: Out_Table = OriginalTable.Clone After that you can write the query in an Assign activity in this way: Out_DT = ( From row in OriginalTable Where row("ID").ToString = "1" Select Out_DT.Rows.Add(row) ).CopyToDataTable In Where statement you have to set the condition to find the row, which you want to copy. I added the condition to check if the ID is equal to 1, but this is only an example, how to set a condition. At the end you will have the row in the Out_DT. If more than one row meet the condition, all rows will be copied to the Out_DT please let me know, if you still have questions! Please also check the video (Filter DataTable). You can find more examples about filtering a table and getting specific rows
@andizaid616
@andizaid616 2 жыл бұрын
@@ActAutomate this is noted . i will try this later . thank you
@ActAutomate
@ActAutomate 2 жыл бұрын
@@andizaid616 Any time ☺
@fwziayasser6933
@fwziayasser6933 2 жыл бұрын
Great video
@ActAutomate
@ActAutomate 2 жыл бұрын
Thanks Fwzia :-)
@abdelrahmanbadr2404
@abdelrahmanbadr2404 2 жыл бұрын
13:06 can you write the pesudo code of the if statement so i can check that i understood it right ? does the compiler execute the condition first or the query ? because Out_DT by default is empty and has no rows so it won't never excute the query even if the sheet contains "Stephan" in the names Coloumn and Ecven if you modified the query to Let A =If(row("Name").ToString.StartsWith("S"),"Yes","No") !... can you explain more so i can clear up this misconception
@ActAutomate
@ActAutomate 2 жыл бұрын
Oh oh sorry about the failure, we wrote the query wrong here. You are correct, we will never goes to the query, because out_DT is always empty at the beginning. So we will always get an empty DataTable. Sorry about it, we wanted to do something else here and we just wrote the wrong query. Please see the video: FilterDataTable using LINQ on the channel. We explained there, how to avoid the exception: The source contains no rows. But for the case how to use IF statement to avoid this exception, we will publish a new video, how to do that using IF. Thanks alot for the comment!
@abdelrahmanbadr2404
@abdelrahmanbadr2404 2 жыл бұрын
@@ActAutomate thank you .. i am waiting for the vedio ... your vedios are very simple and informative Keep up the good work
@dedsec5177
@dedsec5177 3 жыл бұрын
If logic in LINQ is helpfull 👍
@ActAutomate
@ActAutomate 3 жыл бұрын
Exactly. Always in every code, we need somehow the if condition. Also in LINQ it is very helpful to use it
@DrzymalaWagon
@DrzymalaWagon 3 жыл бұрын
I wonder wether there is an other way of handling the empty output exception in case where we are not storing the result in a different DT by adding rows. The only solution i know as for now is to have an IF statement before with the same query but with .Any method instead of .Where
@ActAutomate
@ActAutomate 3 жыл бұрын
Exactly right. We can also use .any function. But in this video, I am talking about if, therefore I used If condition. But .any works also fine ;-)
@robotdream8355
@robotdream8355 3 жыл бұрын
Hi bro, thanks a ton. Do you have any complete course for linq?
@ActAutomate
@ActAutomate 3 жыл бұрын
Unfortunately not. I only post these videos and I will post a new video for each function in LINQ. From Beginners to advanced, that you can learn LINQ completely. But it takes time to do that, therefore just stay informed and please share my channel with your friends. That will help me a lot.
@ravivarma-bq2hn
@ravivarma-bq2hn Жыл бұрын
Hi, can you please tell how we can use linq query to match two columns from two different datable with case insensitive. Kindly help me out. Thanks in advance.
@ActAutomate
@ActAutomate Жыл бұрын
Did you check these videos: Join Function: kzbin.info/www/bejne/sGTWo3pvf9yFaqM DefaultIfEmpty: kzbin.info/www/bejne/l4mpo5KCi8eJjcU If you still need help, please let me know!
@HarishKumar-ur2to
@HarishKumar-ur2to 3 жыл бұрын
Hai sir How to look value from 2 data tables and check only the matching data using linku.. But i have 65000 data in both data tables I tried but I takes more than 3hrs to run the bot.. Please make a vedio sir
@ActAutomate
@ActAutomate 3 жыл бұрын
Hi Harish can you please give me more details about the issue? I didn't understand the problem. Do you mean, you want to join the tables together using one or more columns as a key to have an output table, where you have the values from the both tables in one table?
@HarishKumar-ur2to
@HarishKumar-ur2to 3 жыл бұрын
@@ActAutomate ya i have two different sheets ,each sheet has 65000 rows,my task is to check the matching data from both the sheets. If it matches then it has to write as "matched" in the next column if not match then it should write "not match"
@ActAutomate
@ActAutomate 3 жыл бұрын
@@HarishKumar-ur2to Yes I think you need the Join function. We have Inner Join --> To get only the matches from the both tables in one table. Or we have Left Outer Join and Right Outer Join, where we get all data from the first table with the machtes from the second table. Here we could have empty values, if there is no matches. The video will be online today or tomorrow. Just wait please and let me then know, if you have your answer or if you need any help ;-)
@ActAutomate
@ActAutomate 3 жыл бұрын
@@HarishKumar-ur2to By the way, Join function is more performant than only If condition. I think it should be done in some seconds for the 65000 rows
@HarishKumar-ur2to
@HarishKumar-ur2to 3 жыл бұрын
Tq u so much ur vedios are more helpful for upcoming RPA developers I am fresher in uipath
@souravroy7897
@souravroy7897 Жыл бұрын
Hi @Mahmoud I have one scenario can you help me with this, this is an Excel condition, which I want to convert into IF condition in Linq, the condition is as follows: “=If(COUNTIF(B”+int_RowCounter.ToString+“,”“ati-”“),”“ATI”“, If(COUNTIF(B”+int_RowCounter.ToString+“,”“nasm”“),”“NASM”“, If(COUNTIF(B”+int_RowCounter.ToString+“,”“activity-engines”“),”“ATI”“, If(COUNTIF(B”+int_RowCounter.ToString+“,”“assessments”“),”“ATI”“, If(COUNTIF(B”+int_RowCounter.ToString+“,”“acs-lem”“),”“ASC”“, If(COUNTIF(B”+int_RowCounter.ToString+“,”“lms-”“),”“ASC”“, If(COUNTIF(B”+int_RowCounter.ToString+“,”“aces”“),”“ASC”“, If(COUNTIF(B”+int_RowCounter.ToString+“,”“digital-fulfill”“),”“Clicksafety”“, If(COUNTIF(B”+int_RowCounter.ToString+“,”“clicksafety”“),”“Clicksafety”“, If(COUNTIF(B”+int_RowCounter.ToString+“,”“medhub”“),”“Medhub”“, If(COUNTIF(B”+int_RowCounter.ToString+“,”“examfx”“),”“ExamFX”“, If(COUNTIF(B”+int_RowCounter.ToString+“,”“fisdap”“),”“JBL”“, If(COUNTIF(B”+int_RowCounter.ToString+“,”“CDX”“),”“JBL”“, If(COUNTIF(B”+int_RowCounter.ToString+“,”“JBL”“),”“JBL”“, If(COUNTIF(B”+int_RowCounter.ToString+“,”“certification-services”“),”“ASC”“, If(COUNTIF(B”+int_RowCounter.ToString+“,”“sre”“),”“ASC”“, If(COUNTIF(B”+int_RowCounter.ToString+“,”“ua/”“),”“ASC”“, If(COUNTIF(B”+int_RowCounter.ToString+“,”“asc-”“),”“ASC”“, If(COUNTIF(B”+int_RowCounter.ToString+“,”“f5networks”“),”“ASC”“, If(COUNTIF(B”+int_RowCounter.ToString+“,”“istio”“),”“ASC”“, If(COUNTIF(B”+int_RowCounter.ToString+“,”“vault*”“),”“ASC”“, If(COUNTIF(B”+int_RowCounter.ToString+“,”“moodle3x”“),”“ASC”“, If(COUNTIF(B”+int_RowCounter.ToString+“,”“ascend-crm”“),”“ASC”“, If(COUNTIF(B”+int_RowCounter.ToString+“,”“mitch-test”“),”“ASC”“, If(COUNTIF(B”+int_RowCounter.ToString+“,”“assessment-delivery*”“),”“ATI”“, If(COUNTIF(B”+int_RowCounter.ToString+“,”“remote-proctoring”“),”“ASC”“, If(COUNTIF(B”+int_RowCounter.ToString+“,”“ehrt/”“),”“ATI”“, If(COUNTIF(B”+int_RowCounter.ToString+“,”“assessment-delivery”“),”“ATI”“, If(COUNTIF(B”+int_RowCounter.ToString+“,”“nha-api”“),”“NHA”“, If(COUNTIF(B”+int_RowCounter.ToString+“,”“ascend-sales-transaction”“),”“ASC”“, If(COUNTIF(B”+int_RowCounter.ToString+“,”“crm-userupdate-processor”“),”“NASM”“, If(COUNTIF(B”+int_RowCounter.ToString+“,”“bv/”“),”“Boardvitals”“, If(COUNTIF(B”+int_RowCounter.ToString+“,”“product-package-manager/”“),”“ATI”“, If(COUNTIF(B”+int_RowCounter.ToString+“,”“product-information-management/”“),”“ExamFx”“, If(COUNTIF(B”+int_RowCounter.ToString+“,”“corporate-applications/”“),”“ASC”“, If(COUNTIF(B”+int_RowCounter.ToString+“,”“kognito/”“),”“Kognito”“, If(COUNTIF(B”+int_RowCounter.ToString+“,”“csi-secrets-store/”“),”“ASC”“, If(COUNTIF(B”+int_RowCounter.ToString+“,”“elastic/”“),”“ASC”“, If(COUNTIF(B”+int_RowCounter.ToString+“,”“rancher/”“),”“ASC”“, If(COUNTIF(B”+int_RowCounter.ToString+“,”“newrelic/infra”“),”“ASC”“, If(COUNTIF(B”+int_RowCounter.ToString+“,”“nginx:latest”“),”“BV”“, If(COUNTIF(B”+int_RowCounter.ToString+“,”“gitlab-runner”“),”“ASC”“, If(COUNTIF(B”+int_RowCounter.ToString+“,”“kiali/”“),”“ASC”“, If(COUNTIF(B”+int_RowCounter.ToString+“,”“node-problem-detector/”“),”“ASC”“, If(COUNTIF(B”+int_RowCounter.ToString+“,”“prometheusmsteams/”“),”“ASC”“, If(COUNTIF(B”+int_RowCounter.ToString+“,”“aquasec/”“),”“ASC”“, If(COUNTIF(B”+int_RowCounter.ToString+“,”“kube”“),”“ASC”“, If(COUNTIF(B”+int_RowCounter.ToString+“,”“k8s”“),”“ASC”“, If(COUNTIF(B”+int_RowCounter.ToString+“,”“vault”“),”“ASC”“,”“Unknown Owner”“)))))))))))))))))))))))))))))))))))))))))))))))))” My expected result would be in a data table. Framework is Vb.net. Based on one column value another column value would be determined. Your help would be appreciated on this. If you share one or two expressions, others I can write.
@ActAutomate
@ActAutomate Жыл бұрын
' Assuming you have an Excel data represented as a DataTable Dim excelData As DataTable = GetExcelData() ' Replace this with your actual data retrieval logic ' Define a list of conditions and corresponding values Dim conditionsAndValues As New List(Of KeyValuePair(Of Func(Of DataRow, Boolean), String)) From { New KeyValuePair(Of Func(Of DataRow, Boolean), String)(Function(row) row.Field(Of String)("ColumnB") = "ati-", "ATI"), New KeyValuePair(Of Func(Of DataRow, Boolean), String)(Function(row) row.Field(Of String)("ColumnB") = "nasm", "NASM"), ' Add other conditions and values here... } ' LINQ query to determine the value based on conditions Dim resultDataTable = (From row In excelData.AsEnumerable() Let resultValue = (From kvp In conditionsAndValues Where kvp.Key(row) Select kvp.Value).FirstOrDefault() Select New With { .ColumnB = row.Field(Of String)("ColumnB"), .ResultColumn = If(resultValue IsNot Nothing, resultValue, "Unknown Owner") }).CopyToDataTable()
The evil clown plays a prank on the angel
00:39
超人夫妇
Рет қаралды 53 МЛН
Throw and Rethrow in UiPath | Error Handling in UiPath
26:14
Automate with Rakesh
Рет қаралды 48 М.
Master Grouping Columns in UiPath using LINQ
27:40
Automate with Rakesh
Рет қаралды 4,1 М.
10 Excel Formulas That Will Set You Apart (+Cheat Sheet)
18:04
MyOnlineTrainingHub
Рет қаралды 389 М.
How to Create a Data Entry Form in Excel
34:30
Excel Macro Mastery
Рет қаралды 314 М.