Skip to main content

Notifications

Power Automate - General Discussion
Unanswered

Filter Json Array with Power Automate

(0) ShareShare
ReportReport
Posted on by 28

Hi All, 

 

I am getting below Json array and want to filter values. 

 

[{
   
    "start": {
      "dateTime""2022-07-29T07:00:00.0000000",
      "timeZone""UTC"
    },
    "end": {
      "dateTime""2022-07-29T07:30:00.0000000",
      "timeZone""UTC"
    }
]
 
I used below query to filter the date time time value with current date but its not returning any data. 
 
item()?['start']?['datetime']
 
 
how we use filter query for getting the values. 
 
Categories:
  • DamoBird365 Profile Picture
    DamoBird365 8,942 on at
    Re: Filter Json Array with Power Automate

    @ndpro of course you might just be looking for a way to format the current date? 

    formatDateTime(utcNow(),'yyyy-MM-dd') so that it is the same format as the date in your array.
     
    Damien
  • DamoBird365 Profile Picture
    DamoBird365 8,942 on at
    Re: Filter Json Array with Power Automate

    Hi @ndpro 

     

    You can use a select to repurpose your array and provide an output as follows:

     

    DamoBird365_0-1661500553705.png

     

    I have put your array into a compose (you have a spare , after the last object which I have remove and then I have created the following select:

     

    DamoBird365_1-1661500616865.png

     

    item()?['start/datetime']

    item()?['end/datetime']

     

    If you want to filter on the original array, you can do the following:

     

    DamoBird365_2-1661502369480.png

    I updated the three start dates to 27,28 and 29 and the output was 2 of the 3 objects based on the above filter.


    Cheers
    Damien

    Please take a look and subscribe to my YouTube Channel for more Power Platform ideas and concepts. Thanks

  • ndpro Profile Picture
    ndpro 28 on at
    Re: Filter Json Array with Power Automate

    @VictorIvanidze  I am having same solution for my power automate to filter. its just working only with below type of date time not with my json which i mentioned in above comments 

     

     

    {

    "date":"datetime"

     

    }

  • VictorIvanidze Profile Picture
    VictorIvanidze 11,859 on at
    Re: Filter Json Array with Power Automate

    Have a look at this: https://chercher.tech/power-automate/handling-json-files-power-automate

  • ndpro Profile Picture
    ndpro 28 on at
    Re: Filter Json Array with Power Automate

    @DamoBird365  Thanks for quick response. 

     

    I am not having single object and its containing more than 100 objects. I copied only single object in array. I need to filter whole json file with start datetime with current date.

     

    [{
       
        "start": {
          "dateTime""2022-07-29T07:00:00.0000000",
          "timeZone""UTC"
        },
        "end": {
          "dateTime""2022-07-29T07:30:00.0000000",
          "timeZone""UTC"
        }
    },
    {
       
        "start": {
          "dateTime""2022-07-29T07:00:00.0000000",
          "timeZone""UTC"
        },
        "end": {
          "dateTime""2022-07-29T07:30:00.0000000",
          "timeZone""UTC"
        }
    },
    {
       
        "start": {
          "dateTime""2022-07-29T07:00:00.0000000",
          "timeZone""UTC"
        },
        "end": {
          "dateTime""2022-07-29T07:30:00.0000000",
          "timeZone""UTC"
        }
    },
    ]

     

  • DamoBird365 Profile Picture
    DamoBird365 8,942 on at
    Re: Filter Json Array with Power Automate

    Hi @ndpro 

     

    In your example you have an array with a single object containing a start and end object.  Whilst you can call the start and end object by key name, the main object {} needs to be called by integer index or by using the first() expression.  Item is generally used within a loop / apply to each or select.

     

    But based on what is visible in your question, this should work:

     

    first(item())?['start']?['datetime']

    OR

    item()?[0]?['start']?['datetime']


    Cheers
    Damien

    Please take a look and subscribe to my YouTube Channel for more Power Platform ideas and concepts. Thanks

     

     

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

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,526

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,907

Leaderboard