<?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: EARLIER not working inside filter of virtual table in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/EARLIER-not-working-inside-filter-of-virtual-table/m-p/2404506#M63084</link>
    <description>&lt;P&gt;Thank you&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;can you please explain what is the expected result?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 19 Mar 2022 15:49:27 GMT</pubDate>
    <dc:creator>tamerj1</dc:creator>
    <dc:date>2022-03-19T15:49:27Z</dc:date>
    <item>
      <title>EARLIER not working inside filter of virtual table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/EARLIER-not-working-inside-filter-of-virtual-table/m-p/2403766#M63034</link>
      <description>&lt;P&gt;Hi!&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I'm trying to apply this to a column, but it's not returning the values i expected:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Disponível = &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var&lt;/SPAN&gt; &lt;SPAN&gt;tp&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;TOPN&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;10&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;FILTER&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;Disponibilidade&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;Disponibilidade[Descricao]&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;'Previsão de Entrega'[Grupo]&lt;/SPAN&gt;&lt;SPAN&gt; &amp;amp;&amp;amp; &lt;/SPAN&gt;&lt;SPAN&gt;Disponibilidade[Data]&lt;/SPAN&gt;&lt;SPAN&gt; &amp;gt;= &lt;/SPAN&gt;&lt;SPAN&gt;'Previsão de Entrega'[Sequencia Corrigida]&lt;/SPAN&gt;&lt;SPAN&gt;),&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;Disponibilidade[Data]&lt;/SPAN&gt;&lt;SPAN&gt;,&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;ASC&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;var&lt;/SPAN&gt; &lt;SPAN&gt;temp&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;ADDCOLUMNS&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;tp&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;"Soma"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;CALCULATE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;SUMX&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;tp&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;[Carga Disponível]&lt;/SPAN&gt;&lt;SPAN&gt;),&lt;/SPAN&gt;&lt;SPAN&gt;FILTER&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;tp&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;[Data]&lt;/SPAN&gt;&lt;SPAN&gt;&amp;lt;=&lt;/SPAN&gt;&lt;SPAN&gt;EARLIER&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;[Data]&lt;/SPAN&gt;&lt;SPAN&gt;))))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;RETURN&lt;/SPAN&gt; &lt;SPAN&gt;CALCULATE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;MINX&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;temp&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;[data]&lt;/SPAN&gt;&lt;SPAN&gt;),&lt;/SPAN&gt;&lt;SPAN&gt;FILTER&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;temp&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;[Soma]&lt;/SPAN&gt;&lt;SPAN&gt; &amp;gt; &lt;/SPAN&gt;&lt;SPAN&gt;0&lt;/SPAN&gt;&lt;SPAN&gt;))&lt;BR /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;So i applied this to a new table, replacing the column references with constant values to see what is going on:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;img /&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Seems like the [Data] =&amp;lt; EARLIER([Data]) filter is not working in this context of virtual table. Any tips on how to make it work?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 18 Mar 2022 17:26:10 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/EARLIER-not-working-inside-filter-of-virtual-table/m-p/2403766#M63034</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-03-18T17:26:10Z</dc:date>
    </item>
    <item>
      <title>Re: EARLIER not working inside filter of virtual table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/EARLIER-not-working-inside-filter-of-virtual-table/m-p/2403872#M63042</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;you have nested iterators. I don't to which level of iteration you want to go back. But you can use EARLIEST to go back to the very first one. You can define inside EARLIER how many levels you need to go back. Alternatively you can store in a variable at the desired level.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Mar 2022 18:56:16 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/EARLIER-not-working-inside-filter-of-virtual-table/m-p/2403872#M63042</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-03-18T18:56:16Z</dc:date>
    </item>
    <item>
      <title>Re: EARLIER not working inside filter of virtual table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/EARLIER-not-working-inside-filter-of-virtual-table/m-p/2404009#M63050</link>
      <description>&lt;P&gt;I tried passing 2 as an argument of earlier, but it returns "EARLIER/EARLIEST refers to an earlier row context which doesn't exist."&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I just wanted the sum of "Carga Disponível" where the date is equal or less than the one in the line context of the virtual table "tp"&lt;/P&gt;</description>
      <pubDate>Fri, 18 Mar 2022 20:53:46 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/EARLIER-not-working-inside-filter-of-virtual-table/m-p/2404009#M63050</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-03-18T20:53:46Z</dc:date>
    </item>
    <item>
      <title>Re: EARLIER not working inside filter of virtual table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/EARLIER-not-working-inside-filter-of-virtual-table/m-p/2404230#M63065</link>
      <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You cannot access the row context created by ADDCOLUMNS using EARLIER because you have CALCULATE which performs context transition. Therefore, you have to store it in variable outside CALCULATE&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope this works with you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;Disponível =
VAR tp =
    TOPN (
        10,
        FILTER (
            Disponibilidade,
            Disponibilidade[Descricao] = 'Previsão de Entrega'[Grupo]
                &amp;amp;&amp;amp; Disponibilidade[Data] &amp;gt;= 'Previsão de Entrega'[Sequencia Corrigida]
        ),
        Disponibilidade[Data], ASC
    )
VAR temp =
    ADDCOLUMNS (
        tp,
        "Soma",
            VAR CurrentTPDate = [Date]
            RETURN
                CALCULATE (
                    SUMX ( tp, [Carga Disponível] ),
                    FILTER ( tp, [Data] &amp;lt;= CurrentTPDate )
                )
    )
RETURN
    CALCULATE ( MINX ( temp, [data] ), FILTER ( temp, [Soma] &amp;gt; 0 ) )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 19 Mar 2022 02:48:34 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/EARLIER-not-working-inside-filter-of-virtual-table/m-p/2404230#M63065</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-03-19T02:48:34Z</dc:date>
    </item>
    <item>
      <title>Re: EARLIER not working inside filter of virtual table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/EARLIER-not-working-inside-filter-of-virtual-table/m-p/2404447#M63082</link>
      <description>&lt;P&gt;Tthanks for exlpaining the context issue!&lt;/P&gt;&lt;P&gt;But i tried your code and it still returns the same results, unfortunatelly&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's how it looks on the test table&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 19 Mar 2022 13:35:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/EARLIER-not-working-inside-filter-of-virtual-table/m-p/2404447#M63082</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-03-19T13:35:18Z</dc:date>
    </item>
    <item>
      <title>Re: EARLIER not working inside filter of virtual table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/EARLIER-not-working-inside-filter-of-virtual-table/m-p/2404506#M63084</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;can you please explain what is the expected result?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 19 Mar 2022 15:49:27 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/EARLIER-not-working-inside-filter-of-virtual-table/m-p/2404506#M63084</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-03-19T15:49:27Z</dc:date>
    </item>
    <item>
      <title>Re: EARLIER not working inside filter of virtual table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/EARLIER-not-working-inside-filter-of-virtual-table/m-p/2404990#M63107</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;BR /&gt;try this&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;Disponível =
VAR tp =
    TOPN (
        10,
        FILTER (
            Disponibilidade,
            Disponibilidade[Descricao] = 'Previsão de Entrega'[Grupo]
                &amp;amp;&amp;amp; Disponibilidade[Data] &amp;gt;= 'Previsão de Entrega'[Sequencia Corrigida]
        ),
        Disponibilidade[Data], ASC
    )
VAR temp =
    ADDCOLUMNS (
        tp,
        "Soma",
            VAR CurrentTPDate = [Date]
            RETURN
                SUMX ( FILTER ( tp, [Data] &amp;lt;= CurrentTPDate ), [Carga Disponível] )
    )
RETURN
    CALCULATE ( MINX ( temp, [data] ), FILTER ( temp, [Soma] &amp;gt; 0 ) )&lt;/LI-CODE&gt;</description>
      <pubDate>Sun, 20 Mar 2022 12:41:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/EARLIER-not-working-inside-filter-of-virtual-table/m-p/2404990#M63107</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-03-20T12:41:32Z</dc:date>
    </item>
    <item>
      <title>Re: EARLIER not working inside filter of virtual table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/EARLIER-not-working-inside-filter-of-virtual-table/m-p/2406551#M63210</link>
      <description>&lt;P&gt;That actually worked! Thank you!&lt;/P&gt;</description>
      <pubDate>Mon, 21 Mar 2022 11:29:55 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/EARLIER-not-working-inside-filter-of-virtual-table/m-p/2406551#M63210</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-03-21T11:29:55Z</dc:date>
    </item>
  </channel>
</rss>

