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 / Iterating through user...
Power Automate
Suggested Answer

Iterating through users, getting list of cities

(0) ShareShare
ReportReport
Posted on by
Hey people,
 
I tried chatGPT, I tried Copilot, I tried videos, I tried Google searches, but I can't find any answer (and I assume it should be quite simple).
I want to create a list for my Sharepoint. A list from all 'cities' in the personal information of all users - bonus if cities can be made unique and not show up 100 times.
This is what I have so far (already sorry that it's german):
My thoughts:
-> Trigger (manually for now, no idea how to trigger it)
-> initialize variable (array) empty
-> search for users V2
-> loop through all users
   -> "Select" from previous 'value', map: 'City' value: item()?['city']
   -> "add to array" (City) (output from Select)
-> Create List
 
Last one, creating an element/list is my biggest issue, I have no options to select any output from the previous loop and I don't get why. I have the option to directly select City ('Ort') from the previous 'Search for users' which makes me wonder if I think too complicated or if Power Automate is smart enough to automatically generate an array if I just completely ignore the whole loop inbetween? Also I have no idea how to test it.
 
Thanks in advance :)
Categories:
I have the same question (0)
  • Suggested answer
    David_MA Profile Picture
    14,672 Super User 2026 Season 1 on at
    You can use the Graph API call to get the cities: https://graph.microsoft.com/v1.0/users?$select=city. You can test this using the Graph API Explorer at Graph Explorer | Try Microsoft Graph APIs - Microsoft Graph as you'll need the necessary permissions in Entra ID to make the call.

    Then in your flow, you can use a Union expression on the array to remove duplicate values: (union(variables('YourArray'), variables('YourArray'))
     
    However, you will have one major challenge if your company has more than 1,000 users. When you need to return more than 1,000 rows, you need to implement paging to return all of the values. You can learn about that at Paging Microsoft Graph data in your app - Microsoft Graph | Microsoft Learn. If you get this far, you may need to submit another post, as I have only done this one time and am by no means an expert in implementing this step.

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 632

#2
Haque Profile Picture

Haque 458

#3
Valantis Profile Picture

Valantis 357

Last 30 days Overall leaderboard