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

Announcements

News and Announcements icon
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)
  • Chriddle Profile Picture
    8,644 Super User 2026 Season 1 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.
  • 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,644 Super User 2026 Season 1 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
    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.
  • 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.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 293

#2
David_MA Profile Picture

David_MA 262 Super User 2026 Season 1

#3
Expiscornovus Profile Picture

Expiscornovus 223 Most Valuable Professional

Last 30 days Overall leaderboard