<?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: Comparing Current Price to Previous PRice in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Comparing-Current-Price-to-Previous-PRice/m-p/2128462#M32333</link>
    <description>&lt;P&gt;Hi&amp;nbsp;@Anonymous&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My Sample:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="1.png" style="width: 394px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/610684iEF4DB157B69A727F/image-size/large?v=v2&amp;amp;px=999" role="button" title="1.png" alt="1.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Try measure codes as below.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Current Price = 
VAR _LastDate =
    MAXX (
        FILTER ( ALL ( 'Table' ), 'Table'[Product] = MAX ( 'Table'[Product] ) ),
        'Table'[Date]
    )
VAR _CurrentPrice =
    CALCULATE (
        MAX ( 'Table'[List Price] ),
        FILTER (
            ALL ( 'Table' ),
            AND ( 'Table'[Product] = MAX ( 'Table'[Product] ), 'Table'[Date] = _LastDate )
        )
    )
RETURN
    _CurrentPrice
&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;Previous Price =
VAR _LastDate =
    MAXX (
        FILTER ( ALL ( 'Table' ), 'Table'[Product] = MAX ( 'Table'[Product] ) ),
        'Table'[Date]
    )
VAR _PreviousDate =
    CALCULATE (
        MAX ( 'Table'[Date] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[Product] = MAX ( 'Table'[Product] )
                &amp;amp;&amp;amp; 'Table'[Date] &amp;lt; _LastDate
                &amp;amp;&amp;amp; 'Table'[List Price] &amp;lt;&amp;gt; [Current Price]
        )
    )
VAR _PreviousPrice =
    CALCULATE (
        MAX ( 'Table'[List Price] ),
        FILTER (
            ALL ( 'Table' ),
            AND (
                'Table'[Product] = MAX ( 'Table'[Product] ),
                'Table'[Date] = _PreviousDate
            )
        )
    )
RETURN
    _PreviousPrice&lt;/LI-CODE&gt;
&lt;P&gt;Then create a matrix add Product in Column field in Matrix and add measures in Value field. Then use Show on row function in Matrix format. Result is as below.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="1.png" style="width: 681px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/610683i25F1ECC200A51411/image-size/large?v=v2&amp;amp;px=999" role="button" title="1.png" alt="1.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Rico Zhou&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 12 Oct 2021 03:16:12 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2021-10-12T03:16:12Z</dc:date>
    <item>
      <title>Comparing Current Price to Previous PRice</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Comparing-Current-Price-to-Previous-PRice/m-p/2123622#M32313</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to compare any price changes in our purchase data per SKU. I've figured out to create a measure for the Current price, but need help to create a measure for Previouse price (=The last price before the price change)&lt;BR /&gt;&lt;BR /&gt;Prices can change at any time. The SKU can have multiple rows with the same date, and it is not relevant to just pick the Price from the previous date, since the price probably changed a couple of months ago.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's an example of how the data is structured (obviously working with much larger data than this, thousends of products and data from +1 year back) :&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Date&lt;/TD&gt;&lt;TD&gt;Product&lt;/TD&gt;&lt;TD&gt;List Price&lt;/TD&gt;&lt;TD&gt;Quantity&lt;/TD&gt;&lt;TD&gt;Gross sales&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2021-01-01&lt;/TD&gt;&lt;TD&gt;Product A&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;20&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2021-01-01&lt;/TD&gt;&lt;TD&gt;Product A&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;50&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2021-01-01&lt;/TD&gt;&lt;TD&gt;Product A&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;30&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2021-01-01&lt;/TD&gt;&lt;TD&gt;Product A&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;TD&gt;60&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2021-01-02&lt;/TD&gt;&lt;TD&gt;Product A&lt;/TD&gt;&lt;TD&gt;11&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;44&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2021-01-03&lt;/TD&gt;&lt;TD&gt;Product A&lt;/TD&gt;&lt;TD&gt;11&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;44&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;2021-01-04&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Product A&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;11&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;44&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2021-01-05&lt;/TD&gt;&lt;TD&gt;Product A&lt;/TD&gt;&lt;TD&gt;12&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;12&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2021-04-05&lt;/TD&gt;&lt;TD&gt;Product A&lt;/TD&gt;&lt;TD&gt;12&lt;/TD&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;TD&gt;72&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2021-04-05&lt;/TD&gt;&lt;TD&gt;Product A&lt;/TD&gt;&lt;TD&gt;12&lt;/TD&gt;&lt;TD&gt;7&lt;/TD&gt;&lt;TD&gt;84&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;2021-07-08&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Product A&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;12&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;7&lt;/TD&gt;&lt;TD&gt;84&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So in this example I'd need to pick up:&lt;BR /&gt;&lt;STRONG&gt;Current price = 12&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;Previous price = 11&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;Do you have any good ideas of how I can make a measure for finding the previous price? &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Thanks!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Oct 2021 08:54:33 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Comparing-Current-Price-to-Previous-PRice/m-p/2123622#M32313</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-10-08T08:54:33Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing Current Price to Previous PRice</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Comparing-Current-Price-to-Previous-PRice/m-p/2128462#M32333</link>
      <description>&lt;P&gt;Hi&amp;nbsp;@Anonymous&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My Sample:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="1.png" style="width: 394px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/610684iEF4DB157B69A727F/image-size/large?v=v2&amp;amp;px=999" role="button" title="1.png" alt="1.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Try measure codes as below.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Current Price = 
VAR _LastDate =
    MAXX (
        FILTER ( ALL ( 'Table' ), 'Table'[Product] = MAX ( 'Table'[Product] ) ),
        'Table'[Date]
    )
VAR _CurrentPrice =
    CALCULATE (
        MAX ( 'Table'[List Price] ),
        FILTER (
            ALL ( 'Table' ),
            AND ( 'Table'[Product] = MAX ( 'Table'[Product] ), 'Table'[Date] = _LastDate )
        )
    )
RETURN
    _CurrentPrice
&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;Previous Price =
VAR _LastDate =
    MAXX (
        FILTER ( ALL ( 'Table' ), 'Table'[Product] = MAX ( 'Table'[Product] ) ),
        'Table'[Date]
    )
VAR _PreviousDate =
    CALCULATE (
        MAX ( 'Table'[Date] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[Product] = MAX ( 'Table'[Product] )
                &amp;amp;&amp;amp; 'Table'[Date] &amp;lt; _LastDate
                &amp;amp;&amp;amp; 'Table'[List Price] &amp;lt;&amp;gt; [Current Price]
        )
    )
VAR _PreviousPrice =
    CALCULATE (
        MAX ( 'Table'[List Price] ),
        FILTER (
            ALL ( 'Table' ),
            AND (
                'Table'[Product] = MAX ( 'Table'[Product] ),
                'Table'[Date] = _PreviousDate
            )
        )
    )
RETURN
    _PreviousPrice&lt;/LI-CODE&gt;
&lt;P&gt;Then create a matrix add Product in Column field in Matrix and add measures in Value field. Then use Show on row function in Matrix format. Result is as below.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="1.png" style="width: 681px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/610683i25F1ECC200A51411/image-size/large?v=v2&amp;amp;px=999" role="button" title="1.png" alt="1.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Rico Zhou&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Oct 2021 03:16:12 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Comparing-Current-Price-to-Previous-PRice/m-p/2128462#M32333</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-10-12T03:16:12Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing Current Price to Previous PRice</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Comparing-Current-Price-to-Previous-PRice/m-p/2134675#M32370</link>
      <description>&lt;P&gt;Hi!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for the help! With a few adjustments (had to add some more filters) it worked out on my more complex data as well. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Life saver!&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;/V&lt;/P&gt;</description>
      <pubDate>Thu, 14 Oct 2021 10:10:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Comparing-Current-Price-to-Previous-PRice/m-p/2134675#M32370</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-10-14T10:10:31Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing Current Price to Previous PRice</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Comparing-Current-Price-to-Previous-PRice/m-p/3300748#M43218</link>
      <description>&lt;P&gt;This formula is a killer!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How would you change the dax to filter by vendor for the same product?&amp;nbsp;@Anonymous&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Sat, 24 Jun 2023 13:40:20 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Comparing-Current-Price-to-Previous-PRice/m-p/3300748#M43218</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-06-24T13:40:20Z</dc:date>
    </item>
  </channel>
</rss>

