<?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 While Loop in Quick Measures Gallery</title>
    <link>https://community.fabric.microsoft.com/t5/Quick-Measures-Gallery/While-Loop/m-p/637535#M320</link>
    <description>&lt;P&gt;A way to emulate a traditional "while" loop using DAX. For a detailed explanation, see this article:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.powerbi.com/t5/Community-Blog/For-and-While-Loops-in-DAX/bc-p/637511" target="_blank"&gt;https://community.powerbi.com/t5/Community-Blog/For-and-While-Loops-in-DAX/bc-p/637511&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For a practical implementation, see my "Days of Supply" Quick Measure:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.powerbi.com/t5/Quick-Measures-Gallery/Days-of-Supply/m-p/635656" target="_blank"&gt;https://community.powerbi.com/t5/Quick-Measures-Gallery/Days-of-Supply/m-p/635656&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;While Loop = 
// Provide some starting value via user input
VAR __i = 10
// Generate a "loop table", this will emulate a while loop
VAR __loopTable = GENERATESERIES(1,__i)
// Add in our calculated value, emulating calculations done as iterations over the loop
VAR __loopTable1 = ADDCOLUMNS(__loopTable,"__i",[Value] - 1)
RETURN
COUNTROWS(FILTER(__loopTable1,[__i]&amp;gt;1))+1&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="reportid hidden"&gt;eyJrIjoiOThmZTRjZmQtNjAwMS00NDc4LTg0ZWYtNWZjMWM1YWQ0NGEwIiwidCI6IjRhMDQyNzQzLTM3M2EtNDNkMi04MjdiLTAwM2Y0YzdiYTFlNSIsImMiOjN9&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 05 Mar 2019 19:56:25 GMT</pubDate>
    <dc:creator>Greg_Deckler</dc:creator>
    <dc:date>2019-03-05T19:56:25Z</dc:date>
    <item>
      <title>While Loop</title>
      <link>https://community.fabric.microsoft.com/t5/Quick-Measures-Gallery/While-Loop/m-p/637535#M320</link>
      <description>&lt;P&gt;A way to emulate a traditional "while" loop using DAX. For a detailed explanation, see this article:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.powerbi.com/t5/Community-Blog/For-and-While-Loops-in-DAX/bc-p/637511" target="_blank"&gt;https://community.powerbi.com/t5/Community-Blog/For-and-While-Loops-in-DAX/bc-p/637511&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For a practical implementation, see my "Days of Supply" Quick Measure:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.powerbi.com/t5/Quick-Measures-Gallery/Days-of-Supply/m-p/635656" target="_blank"&gt;https://community.powerbi.com/t5/Quick-Measures-Gallery/Days-of-Supply/m-p/635656&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;While Loop = 
// Provide some starting value via user input
VAR __i = 10
// Generate a "loop table", this will emulate a while loop
VAR __loopTable = GENERATESERIES(1,__i)
// Add in our calculated value, emulating calculations done as iterations over the loop
VAR __loopTable1 = ADDCOLUMNS(__loopTable,"__i",[Value] - 1)
RETURN
COUNTROWS(FILTER(__loopTable1,[__i]&amp;gt;1))+1&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="reportid hidden"&gt;eyJrIjoiOThmZTRjZmQtNjAwMS00NDc4LTg0ZWYtNWZjMWM1YWQ0NGEwIiwidCI6IjRhMDQyNzQzLTM3M2EtNDNkMi04MjdiLTAwM2Y0YzdiYTFlNSIsImMiOjN9&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Mar 2019 19:56:25 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Quick-Measures-Gallery/While-Loop/m-p/637535#M320</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2019-03-05T19:56:25Z</dc:date>
    </item>
  </channel>
</rss>

