Forum Discussion
mastermaq
10 years agoAdvocate I
Stripe not showing all data?
New to Power BI and very impressed so far! I have added Stripe, but it is only showing data from the last couple weeks it appears. Is there a way to change this so that it loads more data?
- 10 years ago
mastermaq I am guessing you're using Stripe Content Pack. Refer to this article which says it currently extracts data over last 30 days. I am guessing since its service content pack you don't have ability to change that. What you can do is submit it as an idea so that it gets noticed and prioritised.
cslau5
6 years agoNew Member
I have recently make this work with M query loop and hope it may help others who need to retrieve historical data with Stripe API
let
iLimit = 100,
getAPIResult = (nextObj) as record =>
let response = if nextObj <> "" then Web.Contents("https://api.stripe.com/v1/refunds",[Query=[limit="100", starting_after=nextObj]])
else Web.Contents("https://api.stripe.com/v1/refunds",[Query=[limit="100"]]),
Source = Json.Document(response),
data = try Source[data] otherwise null,
hasMore = try Source[has_more] otherwise null,
recordCount = List.NonNullCount(data),
lastPosition = recordCount - 1,
lastObj = try Source[data]{lastPosition}[id] otherwise null,
nextObject = lastObj,
next = if hasMore = true then nextObject else null,
res = [Data=data,Next=next]
in
res,
getAPIResult = (nextObj) as record =>
let response = if nextObj <> "" then Web.Contents("https://api.stripe.com/v1/refunds",[Query=[limit="100", starting_after=nextObj]])
else Web.Contents("https://api.stripe.com/v1/refunds",[Query=[limit="100"]]),
Source = Json.Document(response),
data = try Source[data] otherwise null,
hasMore = try Source[has_more] otherwise null,
recordCount = List.NonNullCount(data),
lastPosition = recordCount - 1,
lastObj = try Source[data]{lastPosition}[id] otherwise null,
nextObject = lastObj,
next = if hasMore = true then nextObject else null,
res = [Data=data,Next=next]
in
res,
fullList = List.Generate(() => [i=0, res = getAPIResult("")],
each [i]<iLimit and [res][Data]<>null,
each [i=[i]+1, res = getAPIResult([res][Next])],
each [res][Data]
)
each [i]<iLimit and [res][Data]<>null,
each [i=[i]+1, res = getAPIResult([res][Next])],
each [res][Data]
)
in
fullList
- antoniopower6 years agoRegular Visitor
Thanks so much. It was very usefull!!!