<?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: Previous non-continuous date value in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-non-continuous-date-value/m-p/883873#M7615</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="63535" data-lia-user-login="Oscar_Mtz_V" class="lia-mention lia-mention-user"&gt;Oscar_Mtz_V&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think a good solution would be to create an Index column via Power QUery Editor mode (Add column pane -&amp;gt; Index column)&lt;/P&gt;&lt;P&gt;Then you will be able to do absolutely the same workaround as for date, but for Index column, like&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Previous Value = 
    CALCULATE(
        MAX(Indicators[IndexColumn]),
        ALLEXCEPT(Indicators,Indicators[Country-Indicator]),
        Indicators[IndexColumn]&amp;lt;EARLIER(Indicators[IndexColumn])
    )&lt;/LI-CODE&gt;&lt;P&gt;&lt;STRONG&gt;&lt;I&gt;&lt;FONT color="#ababab"&gt;do not hesitate to give a kudo to useful posts and mark solutions as solution&lt;/FONT&gt;&lt;/I&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://linkedin.com/in/alekseizhukov" target="_blank"&gt;LinkedIn&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 24 Dec 2019 18:22:32 GMT</pubDate>
    <dc:creator>az38</dc:creator>
    <dc:date>2019-12-24T18:22:32Z</dc:date>
    <item>
      <title>Previous non-continuous date value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-non-continuous-date-value/m-p/883700#M7611</link>
      <description>&lt;P&gt;I have a table from where I want to get the value from the previous available date for the specific Country-Indicator. The previous available date can be a day, month or quarter before.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I am available to get the inmediate previous date for the specified "Country-Indicator Key", and this is the formula I need support with twiking.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Previous Date = 
    CALCULATE(
        MAX(Indicators[Date]),
        ALLEXCEPT(Indicators,Indicators[Country-Indicator]),
        Indicators[Date]&amp;lt;EARLIER(Indicators[Date])
    )&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;What I get from the above DAX is a column that shows the previous available date for the specified "Country-Indicator":&lt;/P&gt;&lt;P&gt;&lt;img /&gt;Currently I have a work arround that creates a "Previous Key" and then looks for this value on the table, thus bringing the previous value, this can be either calculated column by column or in a single column:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Previous Value (not Fancy) = 
VAR
PreviousDate = 
    CALCULATE(
        MAX(Indicators[Date]),
        ALLEXCEPT(Indicators,Indicators[Country-Indicator]),
        Indicators[Date]&amp;lt;EARLIER(Indicators[Date])
    )

VAR
PreviousKey = 
FORMAT(PreviousDate,"yyyy-mm-dd")
&amp;amp;"-"&amp;amp;
Indicators[Country-Indicator]

RETURN

LOOKUPVALUE(
    Indicators[Value_Rev],
    Indicators[key],
    PreviousKey
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As mentioned I am looking for a way of modifying the "Previous Date" formulato bring the previous value instead of the previous date. I am just looking for a more elegant solution which I am confident it exists.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the link below you can download the files.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://1drv.ms/u/s!Aj1t-UWaJ-akgbRQhZIcveNiSLfYuQ?e=NE5q2Z" target="_blank" rel="noopener"&gt;https://1drv.ms/u/s!Aj1t-UWaJ-akgbRQhZIcveNiSLfYuQ?e=NE5q2Z&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In advance thanks for your support.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Dec 2019 12:26:09 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-non-continuous-date-value/m-p/883700#M7611</guid>
      <dc:creator>Oscar_Mtz_V</dc:creator>
      <dc:date>2019-12-24T12:26:09Z</dc:date>
    </item>
    <item>
      <title>Re: Previous non-continuous date value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-non-continuous-date-value/m-p/883873#M7615</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="63535" data-lia-user-login="Oscar_Mtz_V" class="lia-mention lia-mention-user"&gt;Oscar_Mtz_V&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think a good solution would be to create an Index column via Power QUery Editor mode (Add column pane -&amp;gt; Index column)&lt;/P&gt;&lt;P&gt;Then you will be able to do absolutely the same workaround as for date, but for Index column, like&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Previous Value = 
    CALCULATE(
        MAX(Indicators[IndexColumn]),
        ALLEXCEPT(Indicators,Indicators[Country-Indicator]),
        Indicators[IndexColumn]&amp;lt;EARLIER(Indicators[IndexColumn])
    )&lt;/LI-CODE&gt;&lt;P&gt;&lt;STRONG&gt;&lt;I&gt;&lt;FONT color="#ababab"&gt;do not hesitate to give a kudo to useful posts and mark solutions as solution&lt;/FONT&gt;&lt;/I&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://linkedin.com/in/alekseizhukov" target="_blank"&gt;LinkedIn&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Dec 2019 18:22:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-non-continuous-date-value/m-p/883873#M7615</guid>
      <dc:creator>az38</dc:creator>
      <dc:date>2019-12-24T18:22:32Z</dc:date>
    </item>
    <item>
      <title>Re: Previous non-continuous date value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-non-continuous-date-value/m-p/1671739#M34185</link>
      <description>&lt;P&gt;Did you solve this problem, if so how?&lt;/P&gt;</description>
      <pubDate>Wed, 17 Feb 2021 12:43:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-non-continuous-date-value/m-p/1671739#M34185</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-02-17T12:43:44Z</dc:date>
    </item>
    <item>
      <title>Re: Previous non-continuous date value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-non-continuous-date-value/m-p/1678637#M34410</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="63535" data-lia-user-login="Oscar_Mtz_V" class="lia-mention lia-mention-user"&gt;Oscar_Mtz_V&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;If the below screenshot is your expected result , please try the below code, you don't need to combine the&amp;nbsp;Country and Indicator as a key, don't need to add an index column in Power Query. Just use DAX code.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;PreviPreviousValue = 
VAR _CurrentDate =
    SELECTEDVALUE ( Sales[Date] )
VAR _PreviousDate =
    CALCULATE (
        MAX ( 'Sales'[Date] ),
        ALLEXCEPT ( Sales, Sales[Country], Sales[Indicator] ),
        KEEPFILTERS ( 'Sales'[Date] &amp;lt; _CurrentDate )
    )
VAR _Result =
    CALCULATE (
        SUM ( Sales[Value_Rev] ),
        'Sales'[Date] = _PreviousDate,
        REMOVEFILTERS ( Sales[Date] )
    )
RETURN
    _Result&lt;/LI-CODE&gt;</description>
      <pubDate>Sat, 20 Feb 2021 14:02:33 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-non-continuous-date-value/m-p/1678637#M34410</guid>
      <dc:creator>jameszhang0805</dc:creator>
      <dc:date>2021-02-20T14:02:33Z</dc:date>
    </item>
    <item>
      <title>Re: Previous non-continuous date value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-non-continuous-date-value/m-p/1756824#M36691</link>
      <description>&lt;P&gt;Why do I keep getting a earlier/earliest refers to earlier row contex that does not exist error??&amp;nbsp; Please help&lt;/P&gt;</description>
      <pubDate>Wed, 31 Mar 2021 08:29:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-non-continuous-date-value/m-p/1756824#M36691</guid>
      <dc:creator>Chris_Botha</dc:creator>
      <dc:date>2021-03-31T08:29:17Z</dc:date>
    </item>
    <item>
      <title>Re: Previous non-continuous date value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-non-continuous-date-value/m-p/1756827#M36692</link>
      <description>&lt;P&gt;I am trying to do this in Power Pivot.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Mar 2021 08:30:36 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-non-continuous-date-value/m-p/1756827#M36692</guid>
      <dc:creator>Chris_Botha</dc:creator>
      <dc:date>2021-03-31T08:30:36Z</dc:date>
    </item>
    <item>
      <title>Re: Previous non-continuous date value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-non-continuous-date-value/m-p/2649487#M78073</link>
      <description>&lt;P&gt;Did you use measure to create this expression? If so, you cannot use earlier/ealiest function&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jul 2022 07:12:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-non-continuous-date-value/m-p/2649487#M78073</guid>
      <dc:creator>miloooooz</dc:creator>
      <dc:date>2022-07-20T07:12:18Z</dc:date>
    </item>
  </channel>
</rss>

