I am trying to check if an excel document has a table, and if it doesn't create one. If it does, don't. The problem I am having is that if I use dynamic content, it goes into for-each loop and the condition will always fail, and is VERY slow.
The Excel document I am working with has 1300 rows.... so the loop is painfully slow. So, I am trying to use expressions manually to skip the for-each. Its a singular check, and shouldn't have to go through each row looking for a table.
Get tables from excel for business (works) -- > Returns [] when no table or ['Table1'] when there is a generic table
Condition:
string(empty(body('Get_tables')?['Value'])) -- > is equal to -- > True | Always returns false.
OR
empty(body('Get_tables')?['Value']) -- > is equal to -- > True | Always returns false
OR
body('Get_tables')?['Value'] -- > is equal to -- > empty() or null | Fails, doesn't like the check
My question is, how do I use the returned value of [] from Get Tables to trigger a TRUE condition and create a table? Future more, if the excel document has a table and returns ['Table1'], don't. It will return FALSE in the condition, but seeing how when its empty it also returns false, I don't trust that its working correctly.
Solved! Go to Solution.
Hi @matchrocket ,
Have you taken a try with @matchrocket 's solution?, @matchrocket 's solution is works, please take a try with it and your poblem could be solved.
length(body('Get_tables')?['value'])
Best regards,
Alice
Community Support Team _ Alice Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @matchrocket,
Try using a condition to check the length of the array returned by "Get tables" as below:
I set up what is hopefully a simple version of what you're trying to do, if not let me know if I misunderstood:
The expression I have used in the condition is:
length(body('Get_tables')?['value'])
which checks the length of the array. As we are just checking the array and not the contents of the array there is no need for a loop.
Let me know if this helps!
Hi @matchrocket ,
Have you taken a try with @matchrocket 's solution?, @matchrocket 's solution is works, please take a try with it and your poblem could be solved.
length(body('Get_tables')?['value'])
Best regards,
Alice
Community Support Team _ Alice Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.