<?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: Second latest date with data in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Second-latest-date-with-data/m-p/2127328#M48801</link>
    <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;try this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;VAR _2nd =
    CALCULATE (
        MAX ( 'Table'[timestamp] ),
        FILTER ( ALL ( 'Table' ), 'Table'[timestamp] &amp;lt; MAX ( 'Table'[timestamp] ) )
    )
RETURN
    CALCULATE ( SUM ( 'Table'[count] ), 'Table'[timestamp] = _2nd )&lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN&gt;output:&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;img /&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;P&gt;If this post&amp;nbsp;&lt;STRONG&gt;helps&lt;/STRONG&gt;, please consider&amp;nbsp;&lt;STRONG&gt;accepting&lt;/STRONG&gt;&lt;STRONG&gt;&lt;EM&gt;&amp;nbsp;it as the solution&amp;nbsp;&lt;/EM&gt;&lt;/STRONG&gt;to help the other members find it more quickly.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Appreciate your Kudos!!&lt;/STRONG&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;BR /&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Mon, 11 Oct 2021 12:46:24 GMT</pubDate>
    <dc:creator>VahidDM</dc:creator>
    <dc:date>2021-10-11T12:46:24Z</dc:date>
    <item>
      <title>Second latest date with data</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Second-latest-date-with-data/m-p/2126407#M48781</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a measure that shows data from the latest possible day and it works as expected. Somehow I fail building a measure for the second latest date because it is always showing data for the next day after latest and new data is not coming in daily. The timestamp value has a relation with the Date table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#00FF00"&gt;Measure for latest works as expected:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;Measure 1 =&lt;/P&gt;&lt;P&gt;var _latestday = CALCULATE(MAX('Date'[Date]))&lt;/P&gt;&lt;P&gt;RETURN&lt;BR /&gt;CALCULATE(SUM('Table'[count]), 'Table'[timestamp] = _latestday)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;Measure for second latest works is returning second latest date even if count is blank.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;Measure 2 =&lt;BR /&gt;var _secondlatestday = CALCULATE(MAX('Date'[Date]))-1&lt;/P&gt;&lt;P&gt;RETURN&lt;BR /&gt;CALCULATE(SUM('Table'[count]), 'Table'[timestamp] = _secondlatestday)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So today Measure 1 is returning 100 and Measure 2 blank when 140 is expeted. On Friday 8th of October Measure 1 was returning 140 and Measure 2 was returning 80. On Friday I thought my measure was working fine but today I realized something needs to be fixed.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;timestamp&lt;/TD&gt;&lt;TD&gt;count&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;10/10/21&lt;/TD&gt;&lt;TD&gt;100&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;8/10/21&lt;/TD&gt;&lt;TD&gt;140&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;7/10/21&lt;/TD&gt;&lt;TD&gt;80&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;5/10/21&lt;/TD&gt;&lt;TD&gt;9&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3/10/21&lt;/TD&gt;&lt;TD&gt;-2&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help in advance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Julia&lt;/P&gt;</description>
      <pubDate>Mon, 11 Oct 2021 07:22:35 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Second-latest-date-with-data/m-p/2126407#M48781</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-10-11T07:22:35Z</dc:date>
    </item>
    <item>
      <title>Re: Second latest date with data</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Second-latest-date-with-data/m-p/2127328#M48801</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;try this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;VAR _2nd =
    CALCULATE (
        MAX ( 'Table'[timestamp] ),
        FILTER ( ALL ( 'Table' ), 'Table'[timestamp] &amp;lt; MAX ( 'Table'[timestamp] ) )
    )
RETURN
    CALCULATE ( SUM ( 'Table'[count] ), 'Table'[timestamp] = _2nd )&lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN&gt;output:&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;img /&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;P&gt;If this post&amp;nbsp;&lt;STRONG&gt;helps&lt;/STRONG&gt;, please consider&amp;nbsp;&lt;STRONG&gt;accepting&lt;/STRONG&gt;&lt;STRONG&gt;&lt;EM&gt;&amp;nbsp;it as the solution&amp;nbsp;&lt;/EM&gt;&lt;/STRONG&gt;to help the other members find it more quickly.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Appreciate your Kudos!!&lt;/STRONG&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;BR /&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 11 Oct 2021 12:46:24 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Second-latest-date-with-data/m-p/2127328#M48801</guid>
      <dc:creator>VahidDM</dc:creator>
      <dc:date>2021-10-11T12:46:24Z</dc:date>
    </item>
    <item>
      <title>Re: Second latest date with data</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Second-latest-date-with-data/m-p/2132894#M48940</link>
      <description>&lt;P&gt;Thanks a lot&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="315278" data-lia-user-login="VahidDM" class="lia-mention lia-mention-user"&gt;VahidDM&lt;/a&gt;&amp;nbsp;! Your solution worked for my problem.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Oct 2021 15:57:52 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Second-latest-date-with-data/m-p/2132894#M48940</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-10-13T15:57:52Z</dc:date>
    </item>
  </channel>
</rss>

