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

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,394 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,394 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

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
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard