<?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 looping through past dates in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/looping-through-past-dates/m-p/2450463#M65926</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hellou guys,&lt;/P&gt;&lt;P&gt;I have problem with example below. I am in some DAX course with exercizes , but even with this result I cant get red highlighted part.&lt;/P&gt;&lt;P&gt;Task was, identify and count new customers in specific day(means, they had purchase first time that date).&lt;/P&gt;&lt;P&gt;Cant get red highlighted part. According my backround from excel I suppose that there is loop via customer key- then inside that is comparing (another loop, but via dates) if ANY of their purchases was before current date of visual(in this case for example first line-1/5/2011..&lt;/P&gt;&lt;P&gt;So their are two loops basicaly..Is that correct thinking, pls?And if so, what exactly is triggering those loops?&lt;/P&gt;&lt;P&gt;SOLUTION:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 11 Apr 2022 19:47:40 GMT</pubDate>
    <dc:creator>Delopiero84</dc:creator>
    <dc:date>2022-04-11T19:47:40Z</dc:date>
    <item>
      <title>looping through past dates</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/looping-through-past-dates/m-p/2450463#M65926</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hellou guys,&lt;/P&gt;&lt;P&gt;I have problem with example below. I am in some DAX course with exercizes , but even with this result I cant get red highlighted part.&lt;/P&gt;&lt;P&gt;Task was, identify and count new customers in specific day(means, they had purchase first time that date).&lt;/P&gt;&lt;P&gt;Cant get red highlighted part. According my backround from excel I suppose that there is loop via customer key- then inside that is comparing (another loop, but via dates) if ANY of their purchases was before current date of visual(in this case for example first line-1/5/2011..&lt;/P&gt;&lt;P&gt;So their are two loops basicaly..Is that correct thinking, pls?And if so, what exactly is triggering those loops?&lt;/P&gt;&lt;P&gt;SOLUTION:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Apr 2022 19:47:40 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/looping-through-past-dates/m-p/2450463#M65926</guid>
      <dc:creator>Delopiero84</dc:creator>
      <dc:date>2022-04-11T19:47:40Z</dc:date>
    </item>
    <item>
      <title>Re: looping through past dates</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/looping-through-past-dates/m-p/2450550#M65933</link>
      <description>&lt;P&gt;Hi:&lt;/P&gt;&lt;P&gt;I can try to explain. Your table or matrix looks like it is on a daily basis. So that sets the filter context. Because you are analyzing by date, in this case MIN or MAX or AVG all are the same thing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SELECTCOLUMNS is an iterator, so it will go row by row and you are basically renaming a column(s). Here you are renaming InternetSales[Customer Key] to "Customer Key". But before doing this (FILTER FIRST-EVALUATE SECOND) you are Filltering &lt;STRONG&gt;all&lt;/STRONG&gt; the order dates(which have customer keys) in the internet sales table for the time period before any date you examine on your date visual.. (Since your currentdate variable is the same as the date you are looking at in your table.) So on Jan 7th you are looking at any date before Jan 7th to see if any customer key comes up to satisfy your variable named Customers2. This is producing a list of every customer who bought before Jan7th.&lt;/P&gt;&lt;P&gt;Your first variable Customers1 is all the customers buying on jan7th.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So your result is figuring any customer who bought on jan7th(Customer1) that had not bought before this date. This makes them new.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope this makes some sense. If your table was monthly, Cusomers1 would be any customer buying in this month and Customers2 would be any customers buying before this month.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Apr 2022 20:53:47 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/looping-through-past-dates/m-p/2450550#M65933</guid>
      <dc:creator>Whitewater100</dc:creator>
      <dc:date>2022-04-11T20:53:47Z</dc:date>
    </item>
    <item>
      <title>Re: looping through past dates</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/looping-through-past-dates/m-p/2450554#M65934</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="377722" data-lia-user-login="Delopiero84" class="lia-mention lia-mention-user"&gt;Delopiero84&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;you should manipulate the Date filter context instead.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;New customer count =
VAR CurrentDate =
    MIN ( 'Date'[Date Key] )
VAR CurrentCustomers =
    VALUES ( 'Internet Sales'[Customer Key] )
VAR OldCustomers =
    CALCULATETABLE (
        VALUES ( 'Internet Sales'[Customer Key] ),
        REMOVEFILTERS ( 'Date' ),
        'Date'[Date Key] &amp;lt;= CurrentDate
    )
RETURN
    COUNTROWS ( EXCEPT ( CurrentCustomers, OldCustomers ) )&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 11 Apr 2022 20:55:00 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/looping-through-past-dates/m-p/2450554#M65934</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-04-11T20:55:00Z</dc:date>
    </item>
  </channel>
</rss>

