Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
joshtwork
New Member

PowerQuery for Slack

Hello,


For the life of me, I can't figure out why this doesn't work. I'm trying to get a list of all users of a Workspace, with pagination. I can't seem to get the if statement to work to build the URL to deal with paging. Maybe my approach is wrong, I don't know.


Advice?

 

let
vUrl = "https://slack.com/api/admin.users.list?team_id=12&limit=2",
vHeaders =[
#"Method"="POST",

#"Authorization"="Bearer " & SlackToken
],
theCursor = "",
GetData =() as table =>
let
url = if theCursor = "" then vUrl else vUrl & "&cursor=" & theCursor,
Source = Json.Document(Web.Contents(url , [Headers=vHeaders])),
tab = Table.Combine({Table.FromList(Source[users], Splitter.SplitByNothing(), null, null, ExtraValues.Error)}),
theCursor = source[response_metadata][next_cursor]
in tab,
Custom1 = List.Generate( () => [LastCount=2,res=GetData()],each [LastCount]<=3,each [LastCount=Table.RowCount([res])+1,res=GetData()],each [res]),
#"Converted to Table" = Table.FromList(Custom1, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Expanded Column1" = Table.ExpandTableColumn(#"Converted to Table", "Column1", {"Column1"}, {"Column1.Column1"}),
#"Expanded Column1.Column1" = Table.ExpandRecordColumn(#"Expanded Column1", "Column1.Column1", {"id", "email", "is_admin", "is_owner", "is_primary_owner", "is_restricted", "is_ultra_restricted", "is_bot"}, {"Column1.Column1.id", "Column1.Column1.email", "Column1.Column1.is_admin", "Column1.Column1.is_owner", "Column1.Column1.is_primary_owner", "Column1.Column1.is_restricted", "Column1.Column1.is_ultra_restricted", "Column1.Column1.is_bot"})
in
#"Expanded Column1.Column1"

1 REPLY 1
v-henryk-mstf
Community Support
Community Support

Hi @joshtwork ,

 

See if the following solutions are helpful to you.

Solved: Power query for pagination - Microsoft Power BI Community


If the problem is still not resolved, please provide detailed error information and let me know immediately. Looking forward to your reply.


Best Regards,
Henry


If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.