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 Automate
Answered

Count occurences

(0) ShareShare
ReportReport
Posted on by 340

Hi guys,

I have an HTTP API call returning devices. I would like a way to count how many of the devices are servers, desktops and laptops. From the API call there are 104 devices

{
 "pageDetails": {
 "count": 104,
 "prevPageUrl": null,
 "nextPageUrl": null
 },
 "devices": [
 {
 "id": 281423,
 "uid": "ccbeb8c4-4e87-0a7a-91e9-c98f8de7b155",
 "siteId": 48083,
 "siteName": "",
 "deviceType": {
 "category": "Server",
 "type": "Main System Chassis"
 },
 },
 {
 "id": 281429,
 "uid": "8d682367-7894-267d-ac29-753b8ba8386e",
 "siteId": 48083,
 "siteName": "",
 "deviceType": {
 "category": "Laptop",
 "type": "Notebook"
 },
 },
 {
 "id": 281429,
 "uid": "8d682367-7894-267d-ac29-753b8ba8386e",
 "siteId": 48083,
 "siteName": "",
 "deviceType": {
 "category": "Desktop",
 "type": "Desktop"
 },
	}

After the HTTP call I added a Compose (Compose 2) action

body('HTTP_2')?['devices']

Then I was thinking of adding a Compose for each category

length(body('Compose_2')) - length(replace(body('Compose_2'), 'laptop', ''))
length(body('Compose_2')) - length(replace(body('Compose_2'), 'desktop', ''))
length(body('Compose_2')) - length(replace(body('Compose_2'), 'server', ''))

 I'm just not sure how to compose that expression for each?

 

Thanks,
David

Categories:
I have the same question (0)
  • SudeepGhatakNZ Profile Picture
    14,396 Most Valuable Professional on at

    @da1ve 

    You could save the output of body('HTTP_2')['Devices'] in a Compose

    And then add some Filter actions to filter each device type.

    You could then apply length() to the output of each filter.

    I can help you if you provide the JSON output form API

     

     

  • da1ve Profile Picture
    340 on at

    Hi @SudeepGhatakNZ , here is the full output (attached)

    Thanks,
    David

     

     

  • Verified answer
    SudeepGhatakNZ Profile Picture
    14,396 Most Valuable Professional on at

    @da1ve ,

     

    Please refer to the attached flow:

    Your JSON is missing a null on line number 108.

    I have also tweaked the JSON schema a bit.

     

  • da1ve Profile Picture
    340 on at

    Thank you @SudeepGhatakNZ that worked as expected

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!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 796

#2
Valantis Profile Picture

Valantis 568

#3
Haque Profile Picture

Haque 538

Last 30 days Overall leaderboard