Forum Discussion
vwiles84
6 years agoHelper III
Rest API - 90 Day restriction
I have access and connected to a rest API to pull in some sales data. The api is restricted to 90 days worth of data. My question is, how do I configure Power BI to pull in current data while archiv...
parry2k
6 years agoSuper User
vwiles84 this M code will create start and end date range and will update daily, just add another column and make api call from the WebURL column and you are good to go.
let
MaxDays = 90,
EndDate = Date.From(DateTime.LocalNow()),
StartDate = Date.AddDays(Date.From(EndDate),1-MaxDays),
Source = #table({"StartDate","EndDate"} ,{{StartDate,EndDate}}),
#"Changed Type1" = Table.TransformColumnTypes(Source,{{"StartDate", type datetime}, {"EndDate", type datetime}}),
#"Added Custom" = Table.AddColumn(#"Changed Type1", "WebURL", each "https://website/order_items?time_start=" &
DateTime.ToText([StartDate],"yyyy-MM-dd")&"&time_end="&DateTime.ToText([EndDate], "yyyy-MM-dd"), type text),
#"Added Custom1" = Table.AddColumn(#"Added Custom", "WebData", each Web.Contents([WebURL]))
in
#"Added Custom1"vwiles84
6 years agoHelper III
Thank you! I will try that and see how it works!