<?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: Tracking cost increase or decrease in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Tracking-cost-increase-or-decrease/m-p/1403056#M25852</link>
    <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="237246" data-lia-user-login="mmunoa" class="lia-mention lia-mention-user"&gt;mmunoa&lt;/a&gt;&amp;nbsp;, Try like&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Cost_MinDate =
var firstdate = maxx('Date','Date'[DATE])
return
calculate (lastnonblankvalue('Date'[DATE],[COST]),
filter (all('Date'),'Date'[ DATE]&amp;lt;firstdate))	&lt;/LI-CODE&gt;</description>
    <pubDate>Wed, 30 Sep 2020 00:34:46 GMT</pubDate>
    <dc:creator>amitchandak</dc:creator>
    <dc:date>2020-09-30T00:34:46Z</dc:date>
    <item>
      <title>Tracking cost increase or decrease</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Tracking-cost-increase-or-decrease/m-p/1401997#M25819</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;First of all, thanks in advance for the help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have to calculate the increase of costs for different product from different suppliers between dates.&lt;BR /&gt;So for that I have a table called "price_history" where every supplier's price list is registered the day it is sended to me, like the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;* The "UPDATE DATE" is a date type colum, not a string like here in the example.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE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gt;&lt;TD&gt;PRODUCT_3&lt;/TD&gt;&lt;TD&gt;101,25&lt;/TD&gt;&lt;TD&gt;SUPPLIER_B&lt;/TD&gt;&lt;TD&gt;July-20&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;PRODUCT_1&lt;/TD&gt;&lt;TD&gt;23,01&lt;/TD&gt;&lt;TD&gt;SUPPLIER_B&lt;/TD&gt;&lt;TD&gt;July-20&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And I have the following measures:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&lt;STRONG&gt;COST&lt;/STRONG&gt;&amp;nbsp;= SUMX('price_history','price_history'[COST])&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Cost_MaxDate&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;=&lt;BR /&gt;var lastdate = maxx('price_history','price_history'[UPDATE DATE])&lt;BR /&gt;return&lt;BR /&gt;calculate ([COST],&lt;BR /&gt;filter ('price_history','price_history'[UPDATE DATE]=lastdate))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Cost_MinDate&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;=&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var firstdate = minx('price_history','price_history'[UPDATE DATE])&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;return&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;calculate ([COST],&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;filter ('price_history','price_history'[UPDATE DATE]=firstdate))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;and then with those two measures (Cost_MinDate and Cost_MaxDate) I finally calculate the % of increase or decrease between values.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;But the problem that I have is that if I filter the date for example between June-19 and July-20 I will have only one value for each product (So % variation is 0), and in that case I don`t want that. In fact, I would like to consider the last previous cost for each item.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Do you know what could I do?&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 29 Sep 2020 13:35:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Tracking-cost-increase-or-decrease/m-p/1401997#M25819</guid>
      <dc:creator>mmunoa</dc:creator>
      <dc:date>2020-09-29T13:35:32Z</dc:date>
    </item>
    <item>
      <title>Re: Tracking cost increase or decrease</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Tracking-cost-increase-or-decrease/m-p/1402019#M25821</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="237246" data-lia-user-login="mmunoa" class="lia-mention lia-mention-user"&gt;mmunoa&lt;/a&gt; , Can you try the Min Cost Like&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cost_MinDate = &lt;BR /&gt;var firstdate = maxx('price_history','price_history'[UPDATE DATE])&lt;BR /&gt;return&lt;BR /&gt;calculate (lastnonblankvalue('price_history'[UPDATE DATE],[COST]),&lt;BR /&gt;filter (all('price_history'),'price_history'[UPDATE DATE]&amp;lt;firstdate))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;or&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cost_MinDate = &lt;BR /&gt;var firstdate = maxx('price_history','price_history'[UPDATE DATE])&lt;BR /&gt;return&lt;BR /&gt;calculate (lastnonblankvalue('price_history'[UPDATE DATE],[COST]),&lt;BR /&gt;filter (all('price_history'),'price_history'[UPDATE DATE]&amp;lt;firstdate &amp;amp;&amp;amp; 'price_history'[product] =max('price_history'[product])))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;or&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cost_MinDate = &lt;BR /&gt;var firstdate = maxx('price_history','price_history'[UPDATE DATE])&lt;BR /&gt;return&lt;BR /&gt;calculate (lastnonblankvalue('price_history'[UPDATE DATE],[COST]),&lt;BR /&gt;filter (all('price_history'),'price_history'[UPDATE DATE]&amp;lt;firstdate &amp;amp;&amp;amp; 'price_history'[product] =max('price_history'[product] &amp;amp;&amp;amp; 'price_history'[SUPPLIER] =max('price_history'[SUPPLIER])))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 13:51:40 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Tracking-cost-increase-or-decrease/m-p/1402019#M25821</guid>
      <dc:creator>amitchandak</dc:creator>
      <dc:date>2020-09-29T13:51:40Z</dc:date>
    </item>
    <item>
      <title>Re: Tracking cost increase or decrease</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Tracking-cost-increase-or-decrease/m-p/1402741#M25840</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="148838" data-lia-user-login="amitchandak" class="lia-mention lia-mention-user"&gt;amitchandak&lt;/a&gt;&amp;nbsp;for helping!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tested it with the three options but it doesn't work, but i forgot to say something:&lt;/P&gt;&lt;P&gt;I also have a calendar table related to the&amp;nbsp;&lt;SPAN&gt;'price_history'[UPDATE DATE] column.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Maybe thats important for understanding better the problem, because when if filter between two dates, I do it on the date table (Which is supposed to filter the price_history table)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 19:50:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Tracking-cost-increase-or-decrease/m-p/1402741#M25840</guid>
      <dc:creator>mmunoa</dc:creator>
      <dc:date>2020-09-29T19:50:49Z</dc:date>
    </item>
    <item>
      <title>Re: Tracking cost increase or decrease</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Tracking-cost-increase-or-decrease/m-p/1403056#M25852</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="237246" data-lia-user-login="mmunoa" class="lia-mention lia-mention-user"&gt;mmunoa&lt;/a&gt;&amp;nbsp;, Try like&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Cost_MinDate =
var firstdate = maxx('Date','Date'[DATE])
return
calculate (lastnonblankvalue('Date'[DATE],[COST]),
filter (all('Date'),'Date'[ DATE]&amp;lt;firstdate))	&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 30 Sep 2020 00:34:46 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Tracking-cost-increase-or-decrease/m-p/1403056#M25852</guid>
      <dc:creator>amitchandak</dc:creator>
      <dc:date>2020-09-30T00:34:46Z</dc:date>
    </item>
    <item>
      <title>Re: Tracking cost increase or decrease</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Tracking-cost-increase-or-decrease/m-p/1409564#M26096</link>
      <description>&lt;P&gt;Thank you very much! It didnt worked just like its expressed here but it gave me the tools and "way of thinking" to solve it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!!!&lt;/P&gt;</description>
      <pubDate>Fri, 02 Oct 2020 12:39:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Tracking-cost-increase-or-decrease/m-p/1409564#M26096</guid>
      <dc:creator>mmunoa</dc:creator>
      <dc:date>2020-10-02T12:39:17Z</dc:date>
    </item>
  </channel>
</rss>

