<?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: Calculate sum product for previous 4 quarters individually in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-sum-product-for-previous-4-quarters-individually/m-p/1623944#M32808</link>
    <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt; , have you tried Datesqtd with date table ?&lt;/P&gt;
&lt;P&gt;example&lt;/P&gt;
&lt;P&gt;QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD(('Date'[Date])))&lt;BR /&gt;Last QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD(dateadd('Date'[Date],-1,QUARTER)))&lt;/P&gt;
&lt;P&gt;Last QUARTER Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD( ENDOFQUARTER(dateadd('Date'[Date],-1,QUARTER))))&lt;BR /&gt;Last QUARTER Sales = CALCULATE(SUM(Sales[Sales Amount]),PREVIOUSQUARTER(('Date'[Date])))&lt;/P&gt;
&lt;P&gt;Last to last QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD(dateadd('Date'[Date],-2,QUARTER)))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Power BI — Qtr on Qtr with or Without Time Intelligence &lt;BR /&gt;&lt;A href="https://medium.com/@amitchandak.1978/power-bi-qtd-questions-time-intelligence-2-5-d842063da839" target="_blank"&gt;https://medium.com/@amitchandak.1978/power-bi-qtd-questions-time-intelligence-2-5-d842063da839&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://www.youtube.com/watch?v=8-TlVx7P0A0" target="_blank"&gt;https://www.youtube.com/watch?v=8-TlVx7P0A0&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 26 Jan 2021 15:21:17 GMT</pubDate>
    <dc:creator>amitchandak</dc:creator>
    <dc:date>2021-01-26T15:21:17Z</dc:date>
    <item>
      <title>Calculate sum product for previous 4 quarters individually</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-sum-product-for-previous-4-quarters-individually/m-p/1623938#M32807</link>
      <description>&lt;P class="lia-align-left"&gt;I'm trying to create 4 DAX measures to calculate sum product of previous 4 quarters based on date selection from slicer. I'm using following DAX function to achieve that:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;avg age qtr-1 = VAR _d1 = MAX(Sheet1[Date])
RETURN CALCULATE(SUMX(Sheet1, Sheet1[Balance] * Sheet1[Acc Age])/SUM(Sheet1[Balance]),DATESINPERIOD(Sheet1[Date],_d1,-3,MONTH))&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;avg age qtr-2 = VAR _d1 = MAX(Sheet1[Date])
RETURN CALCULATE(SUMX(Sheet1, Sheet1[Balance] * Sheet1[Acc Age])/SUM(Sheet1[Balance]),DATESINPERIOD(Sheet1[Date],_d1,-6,MONTH))&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;avg age qtr-3 = VAR _d1 = MAX(Sheet1[Date])
RETURN CALCULATE(SUMX(Sheet1, Sheet1[Balance] * Sheet1[Acc Age])/SUM(Sheet1[Balance]),DATESINPERIOD(Sheet1[Date],_d1,-9,MONTH))&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;avg age qtr-4 = VAR _d1 = MAX(Sheet1[Date])
RETURN CALCULATE(SUMX(Sheet1, Sheet1[Balance] * Sheet1[Acc Age])/SUM(Sheet1[Balance]),DATESINPERIOD(Sheet1[Date],_d1,-12,MONTH))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For some reason the values are not correct in the final output.&amp;nbsp;&lt;/P&gt;&lt;P&gt;For eg, for ID : 1, if I select Dec 31,2020 the correct values are:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sept 30,2020: 48.49&lt;/P&gt;&lt;P&gt;June 30,2020: 55.92&lt;/P&gt;&lt;P&gt;Mar 31,2020: NA&lt;/P&gt;&lt;P&gt;Sept 30, 2020: 57.51&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please suggest any chages in formula or approach.&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;PBIX file is attached here for reference:&amp;nbsp;&lt;A href="https://drive.google.com/file/d/1eV-2kJlpXSMFRne4Pab9Pcc8L_-g6KGO/view?usp=sharing" target="_blank"&gt;https://drive.google.com/file/d/1eV-2kJlpXSMFRne4Pab9Pcc8L_-g6KGO/view?usp=sharing&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jan 2021 15:18:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-sum-product-for-previous-4-quarters-individually/m-p/1623938#M32807</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-01-26T15:18:32Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate sum product for previous 4 quarters individually</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-sum-product-for-previous-4-quarters-individually/m-p/1623944#M32808</link>
      <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt; , have you tried Datesqtd with date table ?&lt;/P&gt;
&lt;P&gt;example&lt;/P&gt;
&lt;P&gt;QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD(('Date'[Date])))&lt;BR /&gt;Last QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD(dateadd('Date'[Date],-1,QUARTER)))&lt;/P&gt;
&lt;P&gt;Last QUARTER Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD( ENDOFQUARTER(dateadd('Date'[Date],-1,QUARTER))))&lt;BR /&gt;Last QUARTER Sales = CALCULATE(SUM(Sales[Sales Amount]),PREVIOUSQUARTER(('Date'[Date])))&lt;/P&gt;
&lt;P&gt;Last to last QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD(dateadd('Date'[Date],-2,QUARTER)))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Power BI — Qtr on Qtr with or Without Time Intelligence &lt;BR /&gt;&lt;A href="https://medium.com/@amitchandak.1978/power-bi-qtd-questions-time-intelligence-2-5-d842063da839" target="_blank"&gt;https://medium.com/@amitchandak.1978/power-bi-qtd-questions-time-intelligence-2-5-d842063da839&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://www.youtube.com/watch?v=8-TlVx7P0A0" target="_blank"&gt;https://www.youtube.com/watch?v=8-TlVx7P0A0&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jan 2021 15:21:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-sum-product-for-previous-4-quarters-individually/m-p/1623944#M32808</guid>
      <dc:creator>amitchandak</dc:creator>
      <dc:date>2021-01-26T15:21:17Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate sum product for previous 4 quarters individually</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-sum-product-for-previous-4-quarters-individually/m-p/1632075#M33070</link>
      <description>&lt;P&gt;&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;I tried your method but it gave me the same avg age for all the IDs. I did some more research and found that I have to release all filters except on ID in order to get correct numbers. I used ALLEXCEPT function to do that. Here's what my final formula looks like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Avg age qtr-1 = CALCULATE(SUMX(Sheet1, Sheet1[Balance] * Sheet1[Acc Age])/SUM(Sheet1[Balance]),ALLEXCEPT(Sheet1,Sheet1[ID]),DATESQTD( ENDOFQUARTER(dateadd('Date'[Date],-3,MONTH))))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jan 2021 14:34:07 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-sum-product-for-previous-4-quarters-individually/m-p/1632075#M33070</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-01-29T14:34:07Z</dc:date>
    </item>
  </channel>
</rss>

