<?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 How to find the last selling date when the product hasn't been sold in the current month in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-find-the-last-selling-date-when-the-product-hasn-t-been/m-p/3980529#M154328</link>
    <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to get the last selling date for the combination of products &amp;amp; articles in a measure. I need the result to be linked to the current row context. I mean that if the product has been sold on May first (01-05) it should return a date prior to this date, and if I look at it on April first (01-04) it should also return a date prior to this date.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My data model is juste made of 4 tables, Sales, Calendar, product &amp;amp; customers. Calendar, Customers and Products linked to sales.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I found a formula that works partially :&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;!--  StartFragment   --&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;Last_Selling_Date:=&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;VAR&lt;/SPAN&gt; &lt;SPAN class=""&gt;Maxdate&lt;/SPAN&gt;&lt;SPAN class=""&gt; = &lt;/SPAN&gt;&lt;SPAN class=""&gt;CALCULATE&lt;/SPAN&gt;&lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;LASTDATE&lt;/SPAN&gt;&lt;SPAN class=""&gt;(Sales[Date]);&lt;/SPAN&gt;&lt;SPAN class=""&gt;FILTER&lt;/SPAN&gt;&lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;ALLEXCEPT&lt;/SPAN&gt;&lt;SPAN class=""&gt;(Sales;Products;Articles);Sales[Date]&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;MIN&lt;/SPAN&gt;&lt;SPAN class=""&gt;(Sales[Date])))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;RETURN&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;Maxdate&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;My problem now, is that the formula works when the product has been sold to the customer this month, but it doesn't work if there hasn't been any sales. There is the results I obtain with the above formula, I've put red crosses where the formula isn't working.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For product 10 &amp;amp; 11 I know for a fact (by checking my data) that a previous date exits.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I think I understand that the filter function create a row context, and obviously if the row with the product and the article doesn't exist on this particular month, it will not show anything.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I solve this problem ? I thought about generating a table with unique values from the calendar table, the product table, and the customer table and then adding a measure giving me the €/Per unit (measure from the sales table). I thought that it would give me a table with all existing values that I could iterate over next but ... I failed to find a solution to do that (if it's a good solution)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm using PowerPivot on Excel.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope I was clear enough, thanks for reading me !&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;!--  EndFragment   --&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 07 Jun 2024 16:26:52 GMT</pubDate>
    <dc:creator>Eb50</dc:creator>
    <dc:date>2024-06-07T16:26:52Z</dc:date>
    <item>
      <title>How to find the last selling date when the product hasn't been sold in the current month</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-find-the-last-selling-date-when-the-product-hasn-t-been/m-p/3980529#M154328</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to get the last selling date for the combination of products &amp;amp; articles in a measure. I need the result to be linked to the current row context. I mean that if the product has been sold on May first (01-05) it should return a date prior to this date, and if I look at it on April first (01-04) it should also return a date prior to this date.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My data model is juste made of 4 tables, Sales, Calendar, product &amp;amp; customers. Calendar, Customers and Products linked to sales.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I found a formula that works partially :&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;!--  StartFragment   --&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;Last_Selling_Date:=&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;VAR&lt;/SPAN&gt; &lt;SPAN class=""&gt;Maxdate&lt;/SPAN&gt;&lt;SPAN class=""&gt; = &lt;/SPAN&gt;&lt;SPAN class=""&gt;CALCULATE&lt;/SPAN&gt;&lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;LASTDATE&lt;/SPAN&gt;&lt;SPAN class=""&gt;(Sales[Date]);&lt;/SPAN&gt;&lt;SPAN class=""&gt;FILTER&lt;/SPAN&gt;&lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;ALLEXCEPT&lt;/SPAN&gt;&lt;SPAN class=""&gt;(Sales;Products;Articles);Sales[Date]&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;MIN&lt;/SPAN&gt;&lt;SPAN class=""&gt;(Sales[Date])))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;RETURN&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;Maxdate&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;My problem now, is that the formula works when the product has been sold to the customer this month, but it doesn't work if there hasn't been any sales. There is the results I obtain with the above formula, I've put red crosses where the formula isn't working.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For product 10 &amp;amp; 11 I know for a fact (by checking my data) that a previous date exits.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I think I understand that the filter function create a row context, and obviously if the row with the product and the article doesn't exist on this particular month, it will not show anything.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I solve this problem ? I thought about generating a table with unique values from the calendar table, the product table, and the customer table and then adding a measure giving me the €/Per unit (measure from the sales table). I thought that it would give me a table with all existing values that I could iterate over next but ... I failed to find a solution to do that (if it's a good solution)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm using PowerPivot on Excel.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope I was clear enough, thanks for reading me !&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;!--  EndFragment   --&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jun 2024 16:26:52 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-find-the-last-selling-date-when-the-product-hasn-t-been/m-p/3980529#M154328</guid>
      <dc:creator>Eb50</dc:creator>
      <dc:date>2024-06-07T16:26:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the last selling date when the product hasn't been sold in the current month</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-find-the-last-selling-date-when-the-product-hasn-t-been/m-p/3980538#M154330</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="751649" data-lia-user-login="Eb50" class="lia-mention lia-mention-user"&gt;Eb50&lt;/a&gt;&amp;nbsp;Perhaps try removing the &amp;lt; MIN('Sales'[Date]) ? That's the only thing I see that could be excluding things.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jun 2024 16:36:36 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-find-the-last-selling-date-when-the-product-hasn-t-been/m-p/3980538#M154330</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2024-06-07T16:36:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the last selling date when the product hasn't been sold in the current month</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-find-the-last-selling-date-when-the-product-hasn-t-been/m-p/3983321#M154442</link>
      <description>&lt;P&gt;Hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="751649" data-lia-user-login="Eb50" class="lia-mention lia-mention-user"&gt;Eb50&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Based on the description, try to modify the dax formula to the following.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Last_Selling_Date = 
VAR CurrentProductArticle = SELECTEDVALUE(Products[ProductID]) &amp;amp; SELECTEDVALUE(Articles[ArticleID])
VAR MaxDateContext = MAX(Calendar[Date])
VAR RelevantSales = 
    FILTER(
        ALL(Sales),
        Sales[ProductID] &amp;amp; Sales[ArticleID] = CurrentProductArticle
        &amp;amp;&amp;amp; Sales[Date] &amp;lt; MaxDateContext
    )
VAR LastSaleDate = MAXX(RelevantSales, Sales[Date])
RETURN
    LastSaleDate&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Wisdom Wu&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If this post&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;helps&lt;/EM&gt;&lt;/STRONG&gt;, then please consider&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Accept it as the solution&lt;/EM&gt;&lt;/STRONG&gt;&amp;nbsp;to help the other members find it more quickly.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jun 2024 10:29:34 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-find-the-last-selling-date-when-the-product-hasn-t-been/m-p/3983321#M154442</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-06-10T10:29:34Z</dc:date>
    </item>
  </channel>
</rss>

