<?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: Help in DAX Building in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-in-DAX-Building/m-p/2371919#M60892</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="355449" data-lia-user-login="apatwal" class="lia-mention lia-mention-user"&gt;apatwal&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can add a Year column to your table&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Year = YEAR('Sample Data'[Week Start Date])&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then create the following measures:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Margin This Year = SUM('Sample Data'[Margin $])&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;Margin Previous Year = 
VAR _thisYear = MAX('Sample Data'[Year])
VAR _thisWeek = MAX('Sample Data'[Week No])
RETURN
CALCULATE(SUM('Sample Data'[Margin $]),ALL('Sample Data'),'Sample Data'[Year]=_thisYear-1,'Sample Data'[Week No]=_thisWeek)&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;Margin Diff = [Margin Previous Year] - 'Sample Data'[Margin This Year]&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;Cumulative Diff =
SUMX (
    FILTER (
        CALCULATETABLE (
            VALUES ( 'Sample Data'[Week Start Date] ),
            ALLEXCEPT ( 'Sample Data', 'Sample Data'[Year] )
        ),
        'Sample Data'[Week Start Date] &amp;lt;= MAX ( 'Sample Data'[Week Start Date] )
    ),
    [Margin Diff]
)
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Drag Week Start Date and measures into a visual. Put Year column into the visual as a filter field and set its value is 2022.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You will get below result.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;* I don't make it month wise in the column chart. In the following example, the week start date of week 5 in 2022 is in January but the same day of 2021 is in February. When they are in different months, the measure may return a wrong result when the axis is month wise.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards, &lt;BR /&gt;Community Support Team _ Jing&lt;BR /&gt;If this post helps, please Accept it as Solution to help other members find it.&lt;/P&gt;</description>
    <pubDate>Thu, 03 Mar 2022 06:54:51 GMT</pubDate>
    <dc:creator>v-jingzhang</dc:creator>
    <dc:date>2022-03-03T06:54:51Z</dc:date>
    <item>
      <title>Help in DAX Building</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-in-DAX-Building/m-p/2364286#M60497</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have below requirement to create DAX.&lt;/P&gt;&lt;P&gt;I need to take difference of margin for 2022 year and 2021 year on weekly basis and plot this in column chart that should show only 2022 year data month wise in normal as well as in a cumulative way.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example :&amp;nbsp;&lt;SPAN&gt;For week of Jan 3, 2022, we need to calculate the week’s total margin and then subtract the margin from week of Jan 4, 2021 and plot this difference month wise on column chart and after that need to take cumulative of these values also.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;For sample records, please find attached PBI file.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://drive.google.com/file/d/1IKBit8nIBFQZL5CqjCVZAuzFjpDR0Ibw/view?usp=sharing" target="_self"&gt;PBI Sample File&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Feb 2022 10:03:52 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-in-DAX-Building/m-p/2364286#M60497</guid>
      <dc:creator>apatwal</dc:creator>
      <dc:date>2022-02-28T10:03:52Z</dc:date>
    </item>
    <item>
      <title>Re: Help in DAX Building</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-in-DAX-Building/m-p/2364372#M60500</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="355449" data-lia-user-login="apatwal" class="lia-mention lia-mention-user"&gt;apatwal&lt;/a&gt; , To get week year behind measure try like example&lt;/P&gt;
&lt;P&gt;week Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-364,DAY)) &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For normal year&lt;/P&gt;
&lt;P&gt;Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Year))&lt;BR /&gt;&lt;BR /&gt;Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),SAMEPERIODLASTYEAR('Date'[Date]))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This should give diff any period vs any period based in grouping&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Time Intelligence, DATESMTD, DATESQTD, DATESYTD, Week On Week, Week Till Date, Custom Period on Period, &lt;BR /&gt;Custom Period till date: &lt;A href="https://youtu.be/aU2aKbnHuWs" target="_blank"&gt;https://youtu.be/aU2aKbnHuWs&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Feb 2022 10:40:56 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-in-DAX-Building/m-p/2364372#M60500</guid>
      <dc:creator>amitchandak</dc:creator>
      <dc:date>2022-02-28T10:40:56Z</dc:date>
    </item>
    <item>
      <title>Re: Help in DAX Building</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-in-DAX-Building/m-p/2371919#M60892</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="355449" data-lia-user-login="apatwal" class="lia-mention lia-mention-user"&gt;apatwal&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can add a Year column to your table&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Year = YEAR('Sample Data'[Week Start Date])&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then create the following measures:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Margin This Year = SUM('Sample Data'[Margin $])&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;Margin Previous Year = 
VAR _thisYear = MAX('Sample Data'[Year])
VAR _thisWeek = MAX('Sample Data'[Week No])
RETURN
CALCULATE(SUM('Sample Data'[Margin $]),ALL('Sample Data'),'Sample Data'[Year]=_thisYear-1,'Sample Data'[Week No]=_thisWeek)&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;Margin Diff = [Margin Previous Year] - 'Sample Data'[Margin This Year]&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;Cumulative Diff =
SUMX (
    FILTER (
        CALCULATETABLE (
            VALUES ( 'Sample Data'[Week Start Date] ),
            ALLEXCEPT ( 'Sample Data', 'Sample Data'[Year] )
        ),
        'Sample Data'[Week Start Date] &amp;lt;= MAX ( 'Sample Data'[Week Start Date] )
    ),
    [Margin Diff]
)
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Drag Week Start Date and measures into a visual. Put Year column into the visual as a filter field and set its value is 2022.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You will get below result.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;* I don't make it month wise in the column chart. In the following example, the week start date of week 5 in 2022 is in January but the same day of 2021 is in February. When they are in different months, the measure may return a wrong result when the axis is month wise.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards, &lt;BR /&gt;Community Support Team _ Jing&lt;BR /&gt;If this post helps, please Accept it as Solution to help other members find it.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Mar 2022 06:54:51 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-in-DAX-Building/m-p/2371919#M60892</guid>
      <dc:creator>v-jingzhang</dc:creator>
      <dc:date>2022-03-03T06:54:51Z</dc:date>
    </item>
  </channel>
</rss>

