web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id : f7xIhVngdXCaMjnAqB079u
Power Automate - Building Flows
Unanswered

How to Optimize Filter Array, Parse JSON, Select Data operations

Like (0) ShareShare
ReportReport
Posted on 2 Mar 2021 13:49:21 by

Hello All,

 

Need some of your advice on how can I optimized the flow I've created. 

 

So basically, I have an SQL get rows statement and then I need to filter the results based on fixed values. The values are from 1.1 to 1.15 and 2.1 to 2.15 respectively. What I did is to filter manually the result just like the image below which is a little bit laborious.

jsdom_0-1614692489864.png

Then i need to Parse JSON the results of the Filter Array which again is repetitive.

jsdom_1-1614692592363.png

Next is to have a select data operation for each individual items.

jsdom_2-1614692714197.png

 

The output from the select data operations is all I'm after. 

The current flow works well but it's too long. All I wanted to do is to shorten the steps if it is possible since it looks like a repeating pattern. 

 

I will appreciate any advice you can give. 😀

 

Thank you,

 

 

I have the same question (0)
  • Paulie78 Profile Picture
    8,418 Moderator on 02 Mar 2021 at 14:28:59
    Re: How to Optimize Filter Array, Parse JSON, Select Data operations

    Do you actually want the separate datasets from 1.1 to 1.15 and 2.1 to 2.15 or are you happy to have them all of them in one filter action?

  • jsdom Profile Picture
    on 02 Mar 2021 at 14:34:42
    Re: How to Optimize Filter Array, Parse JSON, Select Data operations

    Thanks for looking into this @Paulie78 . I actually need the separate datasets which I later use to populate a table in the word template with different sections. 1.1 up to 1.15 and 2.1 up to 2.15 are the different sections.

     

    Thank you 🙂

  • v-yiwenxie-msft Profile Picture
    Microsoft Employee on 09 Mar 2021 at 07:46:43
    Re: How to Optimize Filter Array, Parse JSON, Select Data operations

    Hi @jsdom 

     

    I’ve made a test and have run the flow successfully.

    In my test, I used sharepoint list as an example. Though the connector is different from yours, the logic is the same.

     

    The following flow is for your reference:

    3.9-15.PNG

    The expression used in ‘Filter array’ is:

    @and(greaterOrEquals(float(item()?['OData__x0053_eq2']), float('1.1')),lessOrEquals(float(item()?['OData__x0053_eq2']), float('1.15')))

     

    The 'OData__x0053_eq2' is my column field name though the column display name is ‘Seq2’.

    You can find the column field name in the URL of the column:

    3.9-16.PNG

     

    The expression is meant to get the rows whose ‘Seq2’ is greater than or equal to 1.1 and less than or equal to 1.15.

     

    The same logic applies to the number between 2.1 and 2.15. You just need to change the 1.1 into 2.1 and 1.15 into 2.15 in the expression.

     

    If you still have the problem, please feel free to let me know.

     

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

  • jsdom Profile Picture
    on 09 Mar 2021 at 13:27:03
    Re: How to Optimize Filter Array, Parse JSON, Select Data operations

    @v-yiwenxie-msft Kira Xie,

     

    Apologies if I was not able to explain clearly my problem but I feel like I'm closer to solving it. 

    I am able to shorten the flow by initializing my array ["1.1", "1.2", "1.3"] ... so on. And then by using Apply to each I am able to filter the results using the array that I initialized. Everything works well up to the select data operations.

     

    Now the question is, How can I pass the Outputs  of the  "Select Data" operations to the word template as shown below?

    In the example below, the results are 1.1 and 1.2.

     

    jsdom_1-1615296340702.png

     

    Thank you and regards,

     

    jsdom

     

     

  • v-yiwenxie-msft Profile Picture
    Microsoft Employee on 11 Mar 2021 at 06:21:15
    Re: How to Optimize Filter Array, Parse JSON, Select Data operations

    Hi @jsdom 

     

    Do you mean you want to input the array item '1.1' into the content control '1265266624' and '1.2' into '1595899114'? If yes, I've made a test on my own and have run the flow successfully.

     

    If I've misunderstood, please feel free to let me know.

     

    The following flow is for your reference:

    3.11-7.PNG

    I use an expression in 'Compose' to get the value of the property for the first item in an array.

     

    The outputs of 'Select' is:

    3.11-8.PNG

     

    And the expression used in 'Compose' is:

    body('Select')[0]['select result']
     
    [0] is used to get the first item in an array, [1] is used to get the second item in an array, and so on.
    'Select result' is the property name, and the value for this property in the first item in this array is '1.1'.
     

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

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Chiara Carbone – Community Spotlight

We are honored to recognize Chiara Carbone as our Community Spotlight for November…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 666 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 382 Moderator

#3
developerAJ Profile Picture

developerAJ 254

Last 30 days Overall leaderboard
Loading complete