cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
torbenbj
Level: Powered On

Counting the number of Id´s

HI

How can I count the number of "Id" in this json. Have tried different ways, but no success..

 

 

3 ACCEPTED SOLUTIONS

Accepted Solutions
Dual Super User
Dual Super User

Re: Counting the number of Id´s

Hi @torbenbj 

 

You can use the parse json action to get individual array elements and use an apply to each loop to count each element. The response body contains the array : Value that has an ID componenet in each element. PLease see the screenshot below: ffd.PNG

Schema used in parse json action is: 

{
    "type": "object",
    "properties": {
        "@@odata.context": {
            "type": "string"
        },
        "value": {
            "type": "array",
            "items": {
                "type": "object",
                "properties": {
                    "Id": {
                        "type": "string"
                    },
                    "EnrollmentId": {
                        "type": "string"
                    }
                },
                "required": [
                    "Id",
                    "EnrollmentId"
                ]
            }
        }
    }
}

Hope this Helps!

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

View solution in original post

Super User
Super User

Re: Counting the number of Id´s

Hi @torbenbj  & @yashag2255 ,

 

If the Id elemement is not null then you could do without doing the iteration.

 

Initialise a variable and use the expression

 

length(body('Parse_JSON')?['value'])
 
Please see below
 
le1.png

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up.

 

Thanks

 


Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!



View solution in original post

Community Support Team
Community Support Team

Re: Counting the number of Id´s

Hi @torbenbj ,

 

Have your problem been solved?  If yes, please go ahead and mark the post as solved by clicking “Accept as Solution” so that this thread will be marked for other users to easily identify!

If not, please share more details so we could better undertand your issue and provide a proper workaround for you.

 

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.

View solution in original post

4 REPLIES 4
torbenbj
Level: Powered On

Re: Counting the number of Id´s

And here the json

 

{

  "@odata.context": "https://xxx.xxx.xxx",

  "value": [

    {

      "Id": "1234",

      "EnrollmentId": "abcd"

     

    },

    {

      "Id": "2345",

      "EnrollmentId": "bcde"

    },

    {

      "Id": "3456",

      "EnrollmentId": "cdef"

   

    },

    {

      "Id": "4567",

      "EnrollmentId": "defg"

     

    }

  ]

}

Dual Super User
Dual Super User

Re: Counting the number of Id´s

Hi @torbenbj 

 

You can use the parse json action to get individual array elements and use an apply to each loop to count each element. The response body contains the array : Value that has an ID componenet in each element. PLease see the screenshot below: ffd.PNG

Schema used in parse json action is: 

{
    "type": "object",
    "properties": {
        "@@odata.context": {
            "type": "string"
        },
        "value": {
            "type": "array",
            "items": {
                "type": "object",
                "properties": {
                    "Id": {
                        "type": "string"
                    },
                    "EnrollmentId": {
                        "type": "string"
                    }
                },
                "required": [
                    "Id",
                    "EnrollmentId"
                ]
            }
        }
    }
}

Hope this Helps!

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

View solution in original post

Super User
Super User

Re: Counting the number of Id´s

Hi @torbenbj  & @yashag2255 ,

 

If the Id elemement is not null then you could do without doing the iteration.

 

Initialise a variable and use the expression

 

length(body('Parse_JSON')?['value'])
 
Please see below
 
le1.png

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up.

 

Thanks

 


Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!



View solution in original post

Community Support Team
Community Support Team

Re: Counting the number of Id´s

Hi @torbenbj ,

 

Have your problem been solved?  If yes, please go ahead and mark the post as solved by clicking “Accept as Solution” so that this thread will be marked for other users to easily identify!

If not, please share more details so we could better undertand your issue and provide a proper workaround for you.

 

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.

View solution in original post

Helpful resources

Announcements
firstImage

Better Together Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

firstImage

Incoming: New and improved badges!

Look out for new contribution recognition badges coming SOON!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

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

sixthImage

Community Summit North America

The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (4,730)