<?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 Lookup previous date within table in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookup-previous-date-within-table/m-p/1442860#M27008</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="92178" data-lia-user-login="AlB" class="lia-mention lia-mention-user"&gt;AlB&lt;/a&gt;&amp;nbsp;for getting me this far. Just when I think I'm getting the hang of DAX I run up against a brick wall and can't see the path forward! I'm struggling to find the right words to describe what I'm trying to do, so hopefully the illustration below helps.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The table I have shows start and end dates for a resident and the specific bed and room IDs. I need to add a calculated column that gives in days the time it took to reoccupy the bed. I know I can use DATEDIFF to calculate the number of days between, but I'm struggling with how to lookup the previous EndDate in order to find the difference between that and StartDate. When there isn't a previous date I need to return a blank value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would appreciate any insight on how to accomplish this. Thanks so much!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 19 Oct 2020 18:27:41 GMT</pubDate>
    <dc:creator>rbreneman</dc:creator>
    <dc:date>2020-10-19T18:27:41Z</dc:date>
    <item>
      <title>Lookup previous date within table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookup-previous-date-within-table/m-p/1442860#M27008</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="92178" data-lia-user-login="AlB" class="lia-mention lia-mention-user"&gt;AlB&lt;/a&gt;&amp;nbsp;for getting me this far. Just when I think I'm getting the hang of DAX I run up against a brick wall and can't see the path forward! I'm struggling to find the right words to describe what I'm trying to do, so hopefully the illustration below helps.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The table I have shows start and end dates for a resident and the specific bed and room IDs. I need to add a calculated column that gives in days the time it took to reoccupy the bed. I know I can use DATEDIFF to calculate the number of days between, but I'm struggling with how to lookup the previous EndDate in order to find the difference between that and StartDate. When there isn't a previous date I need to return a blank value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would appreciate any insight on how to accomplish this. Thanks so much!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Oct 2020 18:27:41 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookup-previous-date-within-table/m-p/1442860#M27008</guid>
      <dc:creator>rbreneman</dc:creator>
      <dc:date>2020-10-19T18:27:41Z</dc:date>
    </item>
    <item>
      <title>Re: Lookup previous date within table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookup-previous-date-within-table/m-p/1442893#M27011</link>
      <description>&lt;P&gt;Hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="232555" data-lia-user-login="rbreneman" class="lia-mention lia-mention-user"&gt;rbreneman&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the bed ID is the column you want to identify the bed, then this will give you the previous end date:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;=
CALCULATE (
    MAX ( Table1[EndDate] ),
    Table1[StartDate] &amp;lt; EARLIER ( Table1[StartDate] ),
    ALLEXCEPT ( Table1, Table1[BedID] )
)
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;you can then use that in your datediff. Probably best would be to assign the value above to a VAR. You should also check for blanks, which will come up in cases as the last row, before applying the datediff&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Please mark the question solved when done and consider &lt;FONT color="#FF9900"&gt;giving kudos if posts are helpful.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF0000"&gt;Contact me privately for support with any larger-scale BI needs, tutoring, etc.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;Cheers&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Oct 2020 18:43:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookup-previous-date-within-table/m-p/1442893#M27011</guid>
      <dc:creator>AlB</dc:creator>
      <dc:date>2020-10-19T18:43:42Z</dc:date>
    </item>
    <item>
      <title>Re: Lookup previous date within table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookup-previous-date-within-table/m-p/1450251#M27234</link>
      <description>&lt;P&gt;Sorry for the delay in responding as I got pulled away onto other things. This was perfect! Worked exactly as I hoped. Thank you again so much, really appreciate your help! Have a great day!&lt;/P&gt;</description>
      <pubDate>Thu, 22 Oct 2020 18:09:33 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookup-previous-date-within-table/m-p/1450251#M27234</guid>
      <dc:creator>rbreneman</dc:creator>
      <dc:date>2020-10-22T18:09:33Z</dc:date>
    </item>
  </channel>
</rss>

