<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Change parameter back and forth between 2-3 values for a sequence of query requests in Power Query in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Change-parameter-back-and-forth-between-2-3-values-for-a/m-p/814190#M21049</link>
    <description>Zoe,&lt;BR /&gt;&lt;BR /&gt;Thank you for your answer. Unfortunately, I need to change the between the API keys, whilst still running the same query. In other words: I run the query for ~600 stocks. I need the API keys to change between 2-3 values in a loop while going through the ~600 stock.&lt;BR /&gt;&lt;BR /&gt;Something like this:&lt;BR /&gt;1st stock: 1st key&lt;BR /&gt;2nd stock: 2nd key&lt;BR /&gt;3rd stock: 3rd key&lt;BR /&gt;4th stock: 1st key&lt;BR /&gt;5th stock: 2nd key&lt;BR /&gt;6th stock: 3rd key...&lt;BR /&gt;...&lt;BR /&gt;598th stock: 1st key&lt;BR /&gt;599th stock: 2nd key&lt;BR /&gt;600th stock: 3rd key</description>
    <pubDate>Thu, 10 Oct 2019 02:34:54 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2019-10-10T02:34:54Z</dc:date>
    <item>
      <title>Change parameter back and forth between 2-3 values for a sequence of query requests in Power Query</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Change-parameter-back-and-forth-between-2-3-values-for-a/m-p/812771#M21046</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm running a couple of API requests that pulls all the stock information from a list for hundreds of stocks. Unfortunately, I'm running into a couple of issues:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Because my the API provider only allows 5 calls per minute, I need to use the InvokeAfter feature to delay my call.&lt;/LI&gt;&lt;LI&gt;However due to the number of calls I'm making, my query load time exceeds the 120 minutes on the Power BI service.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;I'm trying to cut down on the time by using multiple API keys to pull the data faster. &lt;EM&gt;&lt;STRONG&gt;Unfortunately, I don't know how to parameterize the pull of API keys dynamically in a Power Query script to switch between 2-3 different keys after each call.&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Meaning:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;First stock is pulled with APIkey_1&lt;/LI&gt;&lt;LI&gt;Second stock is pulled with APIkey_2&lt;/LI&gt;&lt;LI&gt;Third stock is pulled with APIkey_3&lt;/LI&gt;&lt;LI&gt;Forth stock is pulled with APIkey_1 (as i reuse just 2-3 keys without exceeding the allotted 5 calls per API key per minute).&lt;/LI&gt;&lt;LI&gt;Fitfh stock is pulled with APIkey_2&amp;nbsp;(as i reuse just 2-3 keys without exceeding the allotted 5 calls per API key per minute).&lt;/LI&gt;&lt;LI&gt;Sixth stock is pulled with APIkey_3 (as i reuse just 2-3 keys without exceeding the allotted 5 calls per API key per minute).&lt;/LI&gt;&lt;LI&gt;... and so on.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;FYI, here is my query below, relevant pieces are highlighted with &lt;FONT color="#FF0000"&gt;red&lt;/FONT&gt; and &lt;FONT color="#0000FF"&gt;blue&lt;/FONT&gt;. &lt;EM&gt;Also, my query runs fine other than the issue mentioned above.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your answer in advance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;DT&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;let
   &lt;FONT color="#999999"&gt; Source = Json.Document(Web.Contents("https://data.opendatasoft.com/api/records/1.0/search/?dataset=cusip-isin-sp-500-nasdaq-100%40public-us&amp;amp;rows=600")),
    records = Source[records],
    #"Converted to Table" = Table.FromList(records, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"datasetid", "recordid", "fields", "record_timestamp"}, {"datasetid", "recordid", "fields", "record_timestamp"}),
    #"Expanded fields" = Table.ExpandRecordColumn(#"Expanded Column1", "fields", {"cusip_number", "ticker", "company_name", "isin_code"}, {"cusip_number", "ticker", "company_name", "isin_code"}),
    #"Removed Columns" = Table.RemoveColumns(#"Expanded fields",{"datasetid", "recordid", "cusip_number", "isin_code", "record_timestamp"}),&lt;/FONT&gt;
   &lt;FONT color="#FF6600"&gt;&lt;FONT color="#0000FF"&gt; #"Added Custom" = Table.AddColumn(#"Removed Columns", "Custom", each Function.InvokeAfter(()=&amp;gt;Json.Document(Web.Contents("https://www.alphavantage.co/",
    [RelativePath="query?function=TIME_SERIES_DAILY_ADJUSTED&amp;amp;outputsize=full&amp;amp;apikey="&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000FF"&gt; &amp;amp;&lt;/FONT&gt; &lt;FONT color="#FF0000"&gt;APIkey_1&lt;/FONT&gt; &amp;amp; &lt;FONT color="#0000FF"&gt;"&amp;amp;symbol=" &amp;amp; [ticker]])), #duration(0,0,0,6))),&lt;/FONT&gt;
&lt;FONT color="#FF0000"&gt;    //I would like to dynamically change the "APIkey_1" above to "APIkey_2", then "APIkey_3", then back to "APIkey_1", then "APIkey_2", then "APIkey_3", and so on.&lt;/FONT&gt;
&lt;FONT color="#999999"&gt;    #"Expanded Custom" = Table.ExpandRecordColumn(#"Added Custom", "Custom", {"Time Series (Daily)"}, {"TimeSeries"}),
    #"Expanded TimeSeries" = Table.ExpandRecordColumn(#"Expanded Custom", "TimeSeries", Table.ColumnNames(Table.FromRecords(#"Expanded Custom"[TimeSeries]))),
    #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Expanded TimeSeries", {"ticker", "company_name"}, "Attribute", "Value"),
    #"Expanded Value" = Table.ExpandRecordColumn(#"Unpivoted Columns", "Value", {"5. adjusted close", "7. dividend amount"}, {"Value.5. adjusted close", "Value.7. dividend amount"}),
    #"Renamed Columns" = Table.RenameColumns(#"Expanded Value",{{"Attribute", "Date"}, {"Value.5. adjusted close", "Adjusted close"}, {"Value.7. dividend amount", "Dividend"}}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Renamed Columns",{{"Adjusted close", type number}, {"Dividend", type number}}),
    #"Extracted Last Characters" = Table.TransformColumns(#"Changed Type1", {{"Date", each Text.End(_, 10), type text}}),
    #"Parsed Date" = Table.TransformColumns(#"Extracted Last Characters",{{"Date", each Date.From(DateTimeZone.From(_)), type date}}),
    #"Filtered Rows" = Table.SelectRows(#"Parsed Date", each true),
    #"Renamed Columns1" = Table.RenameColumns(#"Filtered Rows",{{"company_name", "Company name"}, {"ticker", "Ticker"}})&lt;/FONT&gt;
in
    #"Renamed Columns1"&lt;/PRE&gt;</description>
      <pubDate>Tue, 08 Oct 2019 18:50:19 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Change-parameter-back-and-forth-between-2-3-values-for-a/m-p/812771#M21046</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-10-08T18:50:19Z</dc:date>
    </item>
    <item>
      <title>Re: Change parameter back and forth between 2-3 values for a sequence of query requests in Power Query</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Change-parameter-back-and-forth-between-2-3-values-for-a/m-p/814175#M21048</link>
      <description>&lt;P&gt;Hi danielntamasi,&lt;/P&gt;
&lt;P&gt;I saw you seems use parameter in your query&amp;nbsp;&amp;nbsp;apikey=&lt;STRONG&gt;" &amp;amp; APIkey_1 &amp;amp; "&lt;/STRONG&gt;&amp;amp;symbol=" &amp;amp; [ticker]. You could try to use query like below&lt;/P&gt;
&lt;PRE&gt;let dynamic1= (&lt;STRONG&gt;api&lt;/STRONG&gt;) =&amp;gt;
let
    Source = Json.Document(Web.Contents("https://data.opendatasoft.com/api/records/1.0/search/?dataset=cusip-isin-sp-500-nasdaq-100%40public-us&amp;amp;rows=600")),
    records = Source[records],
    #"Converted to Table" = Table.FromList(records, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"datasetid", "recordid", "fields", "record_timestamp"}, {"datasetid", "recordid", "fields", "record_timestamp"}),
    #"Expanded fields" = Table.ExpandRecordColumn(#"Expanded Column1", "fields", {"cusip_number", "ticker", "company_name", "isin_code"}, {"cusip_number", "ticker", "company_name", "isin_code"}),
    #"Removed Columns" = Table.RemoveColumns(#"Expanded fields",{"datasetid", "recordid", "cusip_number", "isin_code", "record_timestamp"}),
    #"Added Custom" = Table.AddColumn(#"Removed Columns", "Custom", each Function.InvokeAfter(()=&amp;gt;Json.Document(Web.Contents("https://www.alphavantage.co/",
    [RelativePath="query?function=TIME_SERIES_DAILY_ADJUSTED&amp;amp;outputsize=full&amp;amp;apikey=&lt;STRONG&gt;api&lt;/STRONG&gt;&amp;amp;symbol=" &amp;amp; [ticker]])), #duration(0,0,0,6))),
    //I would like to dynamically change the "APIkey_1" above to "APIkey_2", then "APIkey_3", then back to "APIkey_1", then "APIkey_2", then "APIkey_3", and so on.
    #"Expanded Custom" = Table.ExpandRecordColumn(#"Added Custom", "Custom", {"Time Series (Daily)"}, {"TimeSeries"}),
    #"Expanded TimeSeries" = Table.ExpandRecordColumn(#"Expanded Custom", "TimeSeries", Table.ColumnNames(Table.FromRecords(#"Expanded Custom"[TimeSeries]))),
    #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Expanded TimeSeries", {"ticker", "company_name"}, "Attribute", "Value"),
    #"Expanded Value" = Table.ExpandRecordColumn(#"Unpivoted Columns", "Value", {"5. adjusted close", "7. dividend amount"}, {"Value.5. adjusted close", "Value.7. dividend amount"}),
    #"Renamed Columns" = Table.RenameColumns(#"Expanded Value",{{"Attribute", "Date"}, {"Value.5. adjusted close", "Adjusted close"}, {"Value.7. dividend amount", "Dividend"}}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Renamed Columns",{{"Adjusted close", type number}, {"Dividend", type number}}),
    #"Extracted Last Characters" = Table.TransformColumns(#"Changed Type1", {{"Date", each Text.End(_, 10), type text}}),
    #"Parsed Date" = Table.TransformColumns(#"Extracted Last Characters",{{"Date", each Date.From(DateTimeZone.From(_)), type date}}),
    #"Filtered Rows" = Table.SelectRows(#"Parsed Date", each true),
    #"Renamed Columns1" = Table.RenameColumns(#"Filtered Rows",{{"company_name", "Company name"}, {"ticker", "Ticker"}})
in
    #"Renamed Columns1"
in
    dynamic1&lt;/PRE&gt;
&lt;P&gt;Then you could manage parameter api to use different api key.&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Zoe Zhi&lt;/P&gt;
&lt;P&gt;If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Oct 2019 02:11:25 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Change-parameter-back-and-forth-between-2-3-values-for-a/m-p/814175#M21048</guid>
      <dc:creator>dax</dc:creator>
      <dc:date>2019-10-10T02:11:25Z</dc:date>
    </item>
    <item>
      <title>Re: Change parameter back and forth between 2-3 values for a sequence of query requests in Power Query</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Change-parameter-back-and-forth-between-2-3-values-for-a/m-p/814190#M21049</link>
      <description>Zoe,&lt;BR /&gt;&lt;BR /&gt;Thank you for your answer. Unfortunately, I need to change the between the API keys, whilst still running the same query. In other words: I run the query for ~600 stocks. I need the API keys to change between 2-3 values in a loop while going through the ~600 stock.&lt;BR /&gt;&lt;BR /&gt;Something like this:&lt;BR /&gt;1st stock: 1st key&lt;BR /&gt;2nd stock: 2nd key&lt;BR /&gt;3rd stock: 3rd key&lt;BR /&gt;4th stock: 1st key&lt;BR /&gt;5th stock: 2nd key&lt;BR /&gt;6th stock: 3rd key...&lt;BR /&gt;...&lt;BR /&gt;598th stock: 1st key&lt;BR /&gt;599th stock: 2nd key&lt;BR /&gt;600th stock: 3rd key</description>
      <pubDate>Thu, 10 Oct 2019 02:34:54 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Change-parameter-back-and-forth-between-2-3-values-for-a/m-p/814190#M21049</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-10-10T02:34:54Z</dc:date>
    </item>
    <item>
      <title>Re: Change parameter back and forth between 2-3 values for a sequence of query requests in Power Query</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Change-parameter-back-and-forth-between-2-3-values-for-a/m-p/816968#M21078</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="119281" data-lia-user-login="dax" class="lia-mention lia-mention-user"&gt;dax&lt;/a&gt;, any suggestions for this?&lt;/P&gt;</description>
      <pubDate>Mon, 14 Oct 2019 08:01:09 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Change-parameter-back-and-forth-between-2-3-values-for-a/m-p/816968#M21078</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-10-14T08:01:09Z</dc:date>
    </item>
  </channel>
</rss>

