<?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 [Urgent help request] Monthly weighted average price this year vs last year in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Urgent-help-request-Monthly-weighted-average-price-this-year-vs/m-p/3101835#M156714</link>
    <description>&lt;P&gt;&lt;SPAN&gt;Hi Power BI experts,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I am calculating the inflation impact based on this calculation logic.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;(Monthly weighted average price in this year's month - Monthly weighted average price in previous year's month) * Quantity in this year's month *(-1)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;The basic logic (Pattern A) is done as per the below, but I realized that there are exceptions since we don't have transactions every single month, such as patterns B and C.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Could someone help me with building dynamic DAX logic with this sample data? Big thank you in advance!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;Sample data and detailed explanation:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://docs.google.com/spreadsheets/d/1CIhuSIddVvPKPDFy7m3E98AE4pSeU9WE/edit?usp=share_link&amp;amp;ouid=107681513386535148350&amp;amp;rtpof=true&amp;amp;sd=true\" target="_blank" rel="noopener"&gt;https://docs.google.com/spreadsheets/d/1CIhuSIddVvPKPDFy7m3E98AE4pSeU9WE/edit?usp=share_link&amp;amp;ouid=107681513386535148350&amp;amp;rtpof=true&amp;amp;sd=true&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;This year's month&lt;/TD&gt;&lt;TD&gt;Last year's month&lt;/TD&gt;&lt;TD&gt;Action&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Pattern A&lt;/TD&gt;&lt;TD&gt;Yes&lt;/TD&gt;&lt;TD&gt;Yes&lt;/TD&gt;&lt;TD&gt;Include&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Pattern B&lt;/TD&gt;&lt;TD&gt;No&lt;/TD&gt;&lt;TD&gt;Yes&lt;/TD&gt;&lt;TD&gt;Exclude&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Pattern C&lt;/TD&gt;&lt;TD&gt;Yes&lt;/TD&gt;&lt;TD&gt;No&lt;/TD&gt;&lt;TD&gt;Excule if there is no transaction all the way to 24 months ago.&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Inflation impact =&lt;BR /&gt;var cy = SELECTEDVALUE('Calendar Table'[Year])&lt;BR /&gt;var cm = SELECTEDVALUE('Calendar Table'[Month Number])&lt;BR /&gt;&lt;BR /&gt;var ly = cy - 1&lt;BR /&gt;var cy_items = filter('Data', and(YEAR([Received Date]) = cy, month([Received Date])=cm) )&lt;BR /&gt;var ly_items = filter(ALLSELECTED('Data'),&amp;nbsp; and(YEAR([Received Date]) = ly, month([Received Date])=cm) )&lt;BR /&gt;&lt;BR /&gt;var price_ly = SUMX(ly_items, [Order Unit Price]*[Received Quantity])/sumx(ly_items, [Received Quantity])&lt;BR /&gt;var price_cy = SUMX(cy_items, [Order Unit Price]*[Received Quantity])/sumx(cy_items, [Received Quantity])&lt;BR /&gt;var qty_cy = sumx(cy_items, [Received Quantity])&lt;BR /&gt;&lt;BR /&gt;return (price_cy - price_ly) * qty_cy * -1&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
    <pubDate>Mon, 27 Feb 2023 15:34:26 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2023-02-27T15:34:26Z</dc:date>
    <item>
      <title>[Urgent help request] Monthly weighted average price this year vs last year</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Urgent-help-request-Monthly-weighted-average-price-this-year-vs/m-p/3101835#M156714</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hi Power BI experts,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I am calculating the inflation impact based on this calculation logic.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;(Monthly weighted average price in this year's month - Monthly weighted average price in previous year's month) * Quantity in this year's month *(-1)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;The basic logic (Pattern A) is done as per the below, but I realized that there are exceptions since we don't have transactions every single month, such as patterns B and C.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Could someone help me with building dynamic DAX logic with this sample data? Big thank you in advance!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;Sample data and detailed explanation:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://docs.google.com/spreadsheets/d/1CIhuSIddVvPKPDFy7m3E98AE4pSeU9WE/edit?usp=share_link&amp;amp;ouid=107681513386535148350&amp;amp;rtpof=true&amp;amp;sd=true\" target="_blank" rel="noopener"&gt;https://docs.google.com/spreadsheets/d/1CIhuSIddVvPKPDFy7m3E98AE4pSeU9WE/edit?usp=share_link&amp;amp;ouid=107681513386535148350&amp;amp;rtpof=true&amp;amp;sd=true&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;This year's month&lt;/TD&gt;&lt;TD&gt;Last year's month&lt;/TD&gt;&lt;TD&gt;Action&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Pattern A&lt;/TD&gt;&lt;TD&gt;Yes&lt;/TD&gt;&lt;TD&gt;Yes&lt;/TD&gt;&lt;TD&gt;Include&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Pattern B&lt;/TD&gt;&lt;TD&gt;No&lt;/TD&gt;&lt;TD&gt;Yes&lt;/TD&gt;&lt;TD&gt;Exclude&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Pattern C&lt;/TD&gt;&lt;TD&gt;Yes&lt;/TD&gt;&lt;TD&gt;No&lt;/TD&gt;&lt;TD&gt;Excule if there is no transaction all the way to 24 months ago.&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Inflation impact =&lt;BR /&gt;var cy = SELECTEDVALUE('Calendar Table'[Year])&lt;BR /&gt;var cm = SELECTEDVALUE('Calendar Table'[Month Number])&lt;BR /&gt;&lt;BR /&gt;var ly = cy - 1&lt;BR /&gt;var cy_items = filter('Data', and(YEAR([Received Date]) = cy, month([Received Date])=cm) )&lt;BR /&gt;var ly_items = filter(ALLSELECTED('Data'),&amp;nbsp; and(YEAR([Received Date]) = ly, month([Received Date])=cm) )&lt;BR /&gt;&lt;BR /&gt;var price_ly = SUMX(ly_items, [Order Unit Price]*[Received Quantity])/sumx(ly_items, [Received Quantity])&lt;BR /&gt;var price_cy = SUMX(cy_items, [Order Unit Price]*[Received Quantity])/sumx(cy_items, [Received Quantity])&lt;BR /&gt;var qty_cy = sumx(cy_items, [Received Quantity])&lt;BR /&gt;&lt;BR /&gt;return (price_cy - price_ly) * qty_cy * -1&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Mon, 27 Feb 2023 15:34:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Urgent-help-request-Monthly-weighted-average-price-this-year-vs/m-p/3101835#M156714</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-02-27T15:34:26Z</dc:date>
    </item>
  </channel>
</rss>

