<?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 versus prior year with multiple years of data in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-versus-prior-year-with-multiple-years-of-data/m-p/4057583#M161034</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="476989" data-lia-user-login="alexpegg86" class="lia-mention lia-mention-user"&gt;alexpegg86&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Please try the following measure:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Value Same Period Last Yearr = 
VAR _select_year = SELECTEDVALUE('Total Soft Drinks Output'[Year])
VAR _select_period = SELECTEDVALUE('Total Soft Drinks Output'[Period])
RETURN
CALCULATE(
    SUM('Total Soft Drinks Output'[Spend]),
    FILTER(ALL('Total Soft Drinks Output'),'Total Soft Drinks Output'[Period] = _select_period &amp;amp;&amp;amp; 'Total Soft Drinks Output'[Year] = _select_year-1)
)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Value Same Period Last two Years = 
VAR _select_year = SELECTEDVALUE('Total Soft Drinks Output'[Year])
VAR _select_period = SELECTEDVALUE('Total Soft Drinks Output'[Period])
RETURN
CALCULATE(
    SUM('Total Soft Drinks Output'[Spend]),
    FILTER(ALL('Total Soft Drinks Output'),'Total Soft Drinks Output'[Period] = _select_period &amp;amp;&amp;amp; 'Total Soft Drinks Output'[Year] = _select_year-2)
)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Jayleny&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&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;/P&gt;</description>
    <pubDate>Wed, 24 Jul 2024 02:03:29 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2024-07-24T02:03:29Z</dc:date>
    <item>
      <title>Calculate versus prior year with multiple years of data</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-versus-prior-year-with-multiple-years-of-data/m-p/4056225#M160972</link>
      <description>&lt;DIV&gt;Hi all,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I'm trying to calculate a "versus prior year" calculation in power bi. The complication is that i have 3 years worth of data.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;MAT stands for Moving Annual Total (or last 52 weeks of data)... so MAT is the last 52 weeks, MAT-1 is the previous year of data, and MAT-2 the last year of data.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;So i'm wondering if there's a way in DAX to write a versus prior year measure stating something like "if the date is the current MAT, then calculate MAT vs MAT-1, otherwise if the date is MAT-1, then calculate MAT-1 vs MAT-2".&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;The data i receive is every 4 weeks (so there are 13 data deliveries per year), as you can see in the Period End Date in the data. I've tried using Parallelperiod, and this nearly works, but it falls over when there are two data deliveries within the same period (as you can see in the "Value Same Period Last Year" column for 29/10/2023, as it's adding up the two data deliveries for October 2022).&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;What i'm trying to get to is calculate the value for the equivalent period last year, based off the Period and Year... so P6 2024 equivalent value would be P6 2023, and P6 2023 equivalent value would be P6 2022.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Any help would be welcome! See below a link to the pbix workbook and data file.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Thanks.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Data:&amp;nbsp;&lt;A href="https://drive.google.com/file/d/1dH6Vmr-2iCbWbnYi4-thft0pbYO3CznN/view?usp=drive_link" target="_blank"&gt;https://drive.google.com/file/d/1dH6Vmr-2iCbWbnYi4-thft0pbYO3CznN/view?usp=drive_link&lt;/A&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;PBIX:&amp;nbsp;&lt;A href="https://drive.google.com/file/d/1STRUatexKkVLZO9ugAdCQuxPh8BnwN2c/view?usp=drive_link" target="_blank"&gt;https://drive.google.com/file/d/1STRUatexKkVLZO9ugAdCQuxPh8BnwN2c/view?usp=drive_link&lt;/A&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Tue, 23 Jul 2024 11:07:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-versus-prior-year-with-multiple-years-of-data/m-p/4056225#M160972</guid>
      <dc:creator>alexpegg86</dc:creator>
      <dc:date>2024-07-23T11:07:38Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate versus prior year with multiple years of data</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-versus-prior-year-with-multiple-years-of-data/m-p/4057583#M161034</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="476989" data-lia-user-login="alexpegg86" class="lia-mention lia-mention-user"&gt;alexpegg86&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Please try the following measure:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Value Same Period Last Yearr = 
VAR _select_year = SELECTEDVALUE('Total Soft Drinks Output'[Year])
VAR _select_period = SELECTEDVALUE('Total Soft Drinks Output'[Period])
RETURN
CALCULATE(
    SUM('Total Soft Drinks Output'[Spend]),
    FILTER(ALL('Total Soft Drinks Output'),'Total Soft Drinks Output'[Period] = _select_period &amp;amp;&amp;amp; 'Total Soft Drinks Output'[Year] = _select_year-1)
)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Value Same Period Last two Years = 
VAR _select_year = SELECTEDVALUE('Total Soft Drinks Output'[Year])
VAR _select_period = SELECTEDVALUE('Total Soft Drinks Output'[Period])
RETURN
CALCULATE(
    SUM('Total Soft Drinks Output'[Spend]),
    FILTER(ALL('Total Soft Drinks Output'),'Total Soft Drinks Output'[Period] = _select_period &amp;amp;&amp;amp; 'Total Soft Drinks Output'[Year] = _select_year-2)
)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Jayleny&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&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;/P&gt;</description>
      <pubDate>Wed, 24 Jul 2024 02:03:29 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-versus-prior-year-with-multiple-years-of-data/m-p/4057583#M161034</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-07-24T02:03:29Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate versus prior year with multiple years of data</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-versus-prior-year-with-multiple-years-of-data/m-p/4058626#M161088</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;Anonymous&lt;/a&gt;&amp;nbsp;! That has worked&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jul 2024 09:43:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-versus-prior-year-with-multiple-years-of-data/m-p/4058626#M161088</guid>
      <dc:creator>alexpegg86</dc:creator>
      <dc:date>2024-07-24T09:43:50Z</dc:date>
    </item>
  </channel>
</rss>

