cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
kchakor
Advocate I
Advocate I

array length

Hi ,

 

I need to verify if the array length is greater than 0 . Itry using : @greater(length(body('Get_records_sqlTable')?['value']), 0)

 

but the condition is alway true , even the outputs form my get_records is [] .

 

 

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
v-micsh-msft
Community Support
Community Support

Hi @kchakor,

 

Could we take use of the empty fucntion instead of the length?

For checking if the array is empty, we could using the following formula:

@empty(body('Get_rows')?['value'])

Which would return true if object, array, or string is empty (for array, means no elements, 0 length).

For the formula you used here, try to convert the 0 use the int function:

@greater(length(body('Get_rows')?['value']),int('0'))

See if that would help.

Regards,

Michael

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
v-micsh-msft
Community Support
Community Support

Hi @kchakor,

 

Could we take use of the empty fucntion instead of the length?

For checking if the array is empty, we could using the following formula:

@empty(body('Get_rows')?['value'])

Which would return true if object, array, or string is empty (for array, means no elements, 0 length).

For the formula you used here, try to convert the 0 use the int function:

@greater(length(body('Get_rows')?['value']),int('0'))

See if that would help.

Regards,

Michael

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

it's work fine.

Thank you 

Hi @kchakor,

 

If convenient, would you please accept the workable posts as the solution?

So that others would find it more easily.

 

Regards,

Michael

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

I have a similiar problem where I am building arrays in a for each and only want to create files or tables out of them if they are not empty.  When using the function within a condition:

 

@not(equals(empty(variables('check')), TRUE))  or even @not(equals(empty(variables('check')), bool(1))) or even the length and greater than int(o) , because int('o') throws an expression error for me when trying to save, I still get inconsistent results.

 

It will not producce tables for arrays that have content, and it creates tables for empty arrays - it's just inconsistent in how it evaluates it.  What am I doing wrong here?

Hi @v-micsh-msft 

By any chance can we get current row/line number ..?

Helpful resources

Announcements
MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Users online (2,322)