cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
matchrocket
Level: Power Up

Checking if Excel has a table without using FOR EACH loop.

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.

 

Capture.PNG

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Checking if Excel has a table without using FOR EACH loop.

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.

2 REPLIES 2
jwhite
Level 8

Re: Checking if Excel has a table without using FOR EACH loop.

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:

GetTables.png

 

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!

Community Support Team
Community Support Team

Re: Checking if Excel has a table without using FOR EACH loop.

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.

Helpful resources

Announcements
firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 Release Wave 2 Plan

Power Platform 2019 Release Wave 2 Plan

Features releasing from October 2019 through March 2020

thirdimage

Flow Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Flow Community Video Gallery!

Top Kudoed Authors
Users Online
Currently online: 165 members 4,719 guests
Please welcome our newest community members: