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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Count values from JSON
Power Automate
Answered

Count values from JSON

(0) ShareShare
ReportReport
Posted on by 88
Hi everyone,
 
I'm trying to get devices from Intune via a API Call and want to count the returrned devices.
I successfully get the devices via the API Call.
I then parse the JSON from that API Call output to retrieve the devicename and id (needed later in the flow).
Now I want to count the returned devices and set a variable based on the count, say:
returned device=0 devices found, var=0
returned devices =1 device found, var=1
returned devices > 1, var=more devices found
 
 
 

My next idea was to convert the object returned from the API Call to an array and then count that, but I didn't get this working either.
 
Can someone help me with this?
 
Regards,
Sarah
Categories:
I have the same question (0)
  • Verified answer
    ebels Profile Picture
    88 on at
    Thanks for you help.
    I converted the JSON to an array and then count the entries within the array to check, how many devices where returned from the API call.
  • ebels Profile Picture
    88 on at
    If I check the length of the odata.count then there would be no difference between 0 devices found and 1 device found, correct?
    But I need to check if there was 0, 1 or multiple devices found.
  • Chriddle Profile Picture
    8,464 Super User 2025 Season 2 on at
    If it's just about counting the value length, this is already mentioned in the response:
    Just use it from the Dynamic Content
     
     
    If you don't trust this, use the length function:
    length(body('Parse_JSON')?['value'])
     
     
     
  • ebels Profile Picture
    88 on at
    Hi  @Chriddle,
     
    here's the output of the API Call:
     
    {
      "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#deviceManagement/managedDevices(id,deviceName)",
      "@odata.count": 1,
      "value": [
        {
          "id": "43912cba-0dcc-4794-b166-60ba7d50b01a",
          "deviceName": "my-test-device"
        }
      ]
    }
     
  • Chriddle Profile Picture
    8,464 Super User 2025 Season 2 on at
    I am pretty sure you can do this with 1 expression using xpath().
    But to tell you more, I need an example of the api response.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 245 Super User 2025 Season 2

#2
Expiscornovus Profile Picture

Expiscornovus 207 Most Valuable Professional

#3
trice602 Profile Picture

trice602 185 Super User 2025 Season 2

Last 30 days Overall leaderboard