<?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 Find last value within date range in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Find-last-value-within-date-range/m-p/2935107#M96668</link>
    <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I have trouble getting the appropiate value. I have 3 tables: date (), product and transactions. There is 1 to many link from date to product and transaction.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Measure used:&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;FONT size="1 2 3 4 5 6 7" color="#0000FF"&gt;&lt;SPAN&gt;Prod Desc disregarding filter = &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="1 2 3 4 5 6 7" color="#0000FF"&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;VAR&lt;/SPAN&gt;&lt;SPAN&gt; Currentprod = &lt;/SPAN&gt;&lt;SPAN&gt;SELECTEDVALUE&lt;/SPAN&gt;&lt;SPAN&gt;(TransactionTable[ProductID])&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="1 2 3 4 5 6 7" color="#0000FF"&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;RETURN&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="1 2 3 4 5 6 7" color="#0000FF"&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;MAXX&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="1 2 3 4 5 6 7" color="#0000FF"&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;FILTER&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;ALL&lt;/SPAN&gt;&lt;SPAN&gt;('ProductTable'), ProductTable[ProductID] = &amp;nbsp;Currentprod),&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="1 2 3 4 5 6 7" color="#0000FF"&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ProductTable[Product Description])&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;Current Dax gives me the latest description (March) disregarding the filter selection Jan/Feb. I would like to see Jan description of product 1 when I select Jan and Feb Description of product 1 when I select Feb.&amp;nbsp;&lt;BR /&gt;If I select April, it would give me March (last available data)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;Is there a dax formula that I should be using?&lt;/P&gt;</description>
    <pubDate>Tue, 29 Nov 2022 08:51:05 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2022-11-29T08:51:05Z</dc:date>
    <item>
      <title>Find last value within date range</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Find-last-value-within-date-range/m-p/2935107#M96668</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I have trouble getting the appropiate value. I have 3 tables: date (), product and transactions. There is 1 to many link from date to product and transaction.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Measure used:&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;FONT size="1 2 3 4 5 6 7" color="#0000FF"&gt;&lt;SPAN&gt;Prod Desc disregarding filter = &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="1 2 3 4 5 6 7" color="#0000FF"&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;VAR&lt;/SPAN&gt;&lt;SPAN&gt; Currentprod = &lt;/SPAN&gt;&lt;SPAN&gt;SELECTEDVALUE&lt;/SPAN&gt;&lt;SPAN&gt;(TransactionTable[ProductID])&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="1 2 3 4 5 6 7" color="#0000FF"&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;RETURN&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="1 2 3 4 5 6 7" color="#0000FF"&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;MAXX&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="1 2 3 4 5 6 7" color="#0000FF"&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;FILTER&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;ALL&lt;/SPAN&gt;&lt;SPAN&gt;('ProductTable'), ProductTable[ProductID] = &amp;nbsp;Currentprod),&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="1 2 3 4 5 6 7" color="#0000FF"&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ProductTable[Product Description])&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;Current Dax gives me the latest description (March) disregarding the filter selection Jan/Feb. I would like to see Jan description of product 1 when I select Jan and Feb Description of product 1 when I select Feb.&amp;nbsp;&lt;BR /&gt;If I select April, it would give me March (last available data)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;Is there a dax formula that I should be using?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Nov 2022 08:51:05 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Find-last-value-within-date-range/m-p/2935107#M96668</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-11-29T08:51:05Z</dc:date>
    </item>
    <item>
      <title>Re: Find last value within date range</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Find-last-value-within-date-range/m-p/2935191#M96677</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;BR /&gt;Please try&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;Prod Desc =
VAR Currentprod =
    SELECTEDVALUE ( TransactionTable[ProductID] )
VAR T1 =
    FILTER ( ProductTable, ProductTable[ProductID] = Currentprod )
VAR T2 =
    TOPN ( 1, T1, ProductTable[Date] )
RETURN
    MAXX ( T2, ProductTable[Product Description] )&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 29 Nov 2022 09:07:54 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Find-last-value-within-date-range/m-p/2935191#M96677</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-11-29T09:07:54Z</dc:date>
    </item>
    <item>
      <title>Re: Find last value within date range</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Find-last-value-within-date-range/m-p/2935614#M96721</link>
      <description>&lt;P&gt;Thank you for the quick response.&amp;nbsp;&lt;BR /&gt;I copied the DAX, but it is not giving the desired result.&lt;BR /&gt;It is giving me the description of product 1 in Feb, but I lost the last available information of product 2 and 3.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;The desired result should be:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;By the way, here is the link to the &lt;A title="pbix file" href="https://1drv.ms/u/s!At21bEQZJ6Lxl2U4pLeG6WYe-Lhq?e=iS6gEu" target="_self"&gt;File.&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Nov 2022 12:13:54 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Find-last-value-within-date-range/m-p/2935614#M96721</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-11-29T12:13:54Z</dc:date>
    </item>
    <item>
      <title>Re: Find last value within date range</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Find-last-value-within-date-range/m-p/2935726#M96726</link>
      <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;BR /&gt;If you haven't shared the file, I wouldn't in a milion years figure out that in fact the Dates in the Product Table are in 2022 while the Dates in the Transaction Table are in 2018. The Dates in the Product Table do not even exist in the Date table! I was about to go crazy woundering why The Product Table do not exist inside the matrix even if the three months are were selected.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please refer to your sample file amended with the solution&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;Prod Descr = 
VAR Currentprod =
    SELECTEDVALUE ('TransactionTable'[ProductID])
VAR T1 =
    CALCULATETABLE ( 
        ProductTable,
        ALL ( DateTable ),
        ProductTable[ProductID] = Currentprod,
        MONTH ( ProductTable[Date] ) &amp;lt;= MONTH ( MAX ( DateTable[Date] ) )
    )
VAR T2 =
    TOPN ( 1, T1, ProductTable[Date] )
VAR Result =
    MAXX ( T2, ProductTable[Product Description] )
RETURN
    Result&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Nov 2022 13:27:21 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Find-last-value-within-date-range/m-p/2935726#M96726</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-11-29T13:27:21Z</dc:date>
    </item>
    <item>
      <title>Re: Find last value within date range</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Find-last-value-within-date-range/m-p/2935972#M96752</link>
      <description>&lt;P&gt;Sorry about the dates. I discovered the date after the initial upload and have reuploaded the file. But I was too late.&amp;nbsp;&lt;BR /&gt;Thank you for the solution. I have some excel background, but the transition to dax is not easy. Online tutorials and the&amp;nbsp;&lt;A href="https://learn.microsoft.com/" target="_blank"&gt;https://learn.microsoft.com/&lt;/A&gt;&amp;nbsp;are a bit weak in the department of combining Dax funtions.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Nov 2022 13:50:53 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Find-last-value-within-date-range/m-p/2935972#M96752</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-11-29T13:50:53Z</dc:date>
    </item>
    <item>
      <title>Re: Find last value within date range</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Find-last-value-within-date-range/m-p/2936141#M96773</link>
      <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the dates are fixed then the first solution should work.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Nov 2022 14:36:59 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Find-last-value-within-date-range/m-p/2936141#M96773</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-11-29T14:36:59Z</dc:date>
    </item>
    <item>
      <title>Re: Find last value within date range</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Find-last-value-within-date-range/m-p/2937842#M96919</link>
      <description>&lt;P&gt;Yes it is working now. I also marked "accept as solution" yesterday.&amp;nbsp;&lt;BR /&gt;FIrst post was a success :). Start of a new journey to get to know PowerBI.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Nov 2022 07:16:53 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Find-last-value-within-date-range/m-p/2937842#M96919</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-11-30T07:16:53Z</dc:date>
    </item>
  </channel>
</rss>

