<?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 difference between values of two years in the same column in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-difference-between-values-of-two-years-in-the-same/m-p/3852461#M150511</link>
    <description>&lt;P&gt;Hi&amp;nbsp; &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="648132" data-lia-user-login="BIUser1998" class="lia-mention lia-mention-user"&gt;BIUser1998&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What type of comparison do you want to do?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;There are many ways of comparing if the Data Model is constructed correctly, using Time Intelligence, you should look into this when you have time.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;These will get you on your way&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Create a base measure&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Total Value =
SUM('Table1'[Value])&lt;/LI-CODE&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;PY&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;PY = CALCULATE([Total Value],
KEEPFILTERS(MAX(Table1[Year]) - 1 = Table1[Year]))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then this measure to show the difference to last year&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt; PY Diff = [PY]- [Total Value]&lt;/LI-CODE&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;This will show the % deviation&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;% Deviation = 
DIVIDE( [Diff PY], [PY], 0)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&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;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps&lt;/P&gt;&lt;P&gt;Joe&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;If you found my answer helpful and it solved your issue, please accept as solution&lt;/EM&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;</description>
    <pubDate>Fri, 19 Apr 2024 06:33:30 GMT</pubDate>
    <dc:creator>Joe_Barry</dc:creator>
    <dc:date>2024-04-19T06:33:30Z</dc:date>
    <item>
      <title>Calculate difference between values of two years in the same column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-difference-between-values-of-two-years-in-the-same/m-p/3851761#M150503</link>
      <description>&lt;P&gt;I have a data table consisting of two columns: Year and Value as follows&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Year&lt;/TD&gt;&lt;TD&gt;Value&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2023&lt;/TD&gt;&lt;TD&gt;30&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2023&lt;/TD&gt;&lt;TD&gt;20&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2024&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;10&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2024&lt;/TD&gt;&lt;TD&gt;60&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;I want to calculate the difference between the two years over here. The problem is that I cannot user a slicer and cannot hard code the years either&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried doing something like&amp;nbsp;&lt;/P&gt;&lt;P&gt;SumofVal = SUM(Table[Value])&lt;/P&gt;&lt;P&gt;Diff = [SumofVal] - [SumofVal] and dragging the Year filter twice into the Filters Pane (doesn't make any sense I know) but I was wondering if there's a way of achieving this without slicers. Also if it helps, we will always be comparing the current year with the previous year.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help with the same would be appreciated. Thank you.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Apr 2024 04:32:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-difference-between-values-of-two-years-in-the-same/m-p/3851761#M150503</guid>
      <dc:creator>BIUser1998</dc:creator>
      <dc:date>2024-04-19T04:32:43Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate difference between values of two years in the same column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-difference-between-values-of-two-years-in-the-same/m-p/3852422#M150509</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="648132" data-lia-user-login="BIUser1998" class="lia-mention lia-mention-user"&gt;BIUser1998&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;try below measure&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Measure = 
var a = SUMX(FILTER(ALL('Table'[Year],'Table'[Value]),'Table'[Year]=MAX('Table'[Year])),'Table'[Value])
var b = MAXX(FILTER(ALL('Table'[Year],'Table'[Value]),'Table'[Year]&amp;lt;MAX('Table'[Year])), 'Table'[Year])
var c= SUMX(FILTER(ALL('Table'[Year],'Table'[Value]),'Table'[Year]=b),'Table'[Value])
RETURN
a-c&lt;/LI-CODE&gt;
&lt;P&gt;&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;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Apr 2024 06:21:29 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-difference-between-values-of-two-years-in-the-same/m-p/3852422#M150509</guid>
      <dc:creator>Dangar332</dc:creator>
      <dc:date>2024-04-19T06:21:29Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate difference between values of two years in the same column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-difference-between-values-of-two-years-in-the-same/m-p/3852461#M150511</link>
      <description>&lt;P&gt;Hi&amp;nbsp; &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="648132" data-lia-user-login="BIUser1998" class="lia-mention lia-mention-user"&gt;BIUser1998&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What type of comparison do you want to do?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;There are many ways of comparing if the Data Model is constructed correctly, using Time Intelligence, you should look into this when you have time.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;These will get you on your way&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Create a base measure&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Total Value =
SUM('Table1'[Value])&lt;/LI-CODE&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;PY&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;PY = CALCULATE([Total Value],
KEEPFILTERS(MAX(Table1[Year]) - 1 = Table1[Year]))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then this measure to show the difference to last year&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt; PY Diff = [PY]- [Total Value]&lt;/LI-CODE&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;This will show the % deviation&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;% Deviation = 
DIVIDE( [Diff PY], [PY], 0)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&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;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps&lt;/P&gt;&lt;P&gt;Joe&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;If you found my answer helpful and it solved your issue, please accept as solution&lt;/EM&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;</description>
      <pubDate>Fri, 19 Apr 2024 06:33:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-difference-between-values-of-two-years-in-the-same/m-p/3852461#M150511</guid>
      <dc:creator>Joe_Barry</dc:creator>
      <dc:date>2024-04-19T06:33:30Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate difference between values of two years in the same column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-difference-between-values-of-two-years-in-the-same/m-p/3853031#M150533</link>
      <description>&lt;P&gt;Hi,&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="648132" data-lia-user-login="BIUser1998" class="lia-mention lia-mention-user"&gt;BIUser1998&lt;/a&gt;&amp;nbsp;.I'd be happy to help you.&lt;BR /&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="569583" data-lia-user-login="Dangar332" class="lia-mention lia-mention-user"&gt;Dangar332&lt;/a&gt;&amp;nbsp;,&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="707963" data-lia-user-login="Joe_Barry" class="lia-mention lia-mention-user"&gt;Joe_Barry&lt;/a&gt;&amp;nbsp;, thanks for your concern about this case .&lt;/P&gt;&lt;P&gt;Your solutions are great. Here I have another similar idea in mind, and I would like to share it for reference.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;The Dax function is shown below:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;If your goal is to subtract the sum of each year's values from the sum of the previous year's values, you can try this measure:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;M_1 =
VAR SumCurrentYear =
    CALCULATE (
        SUM ( 'Table'[Value] ),
        FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Year] = MAX ( 'Table'[Year] ) )
    )
VAR SumlastYear =
    CALCULATE (
        SUM ( 'Table'[Value] ),
        FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Year] = MAX ( 'Table'[Year] ) - 1 )
    )
RETURN
    SumCurrentYear - SumlastYear&lt;/LI-CODE&gt;&lt;P&gt;I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.&lt;/P&gt;&lt;P&gt;Best Regards,&lt;BR /&gt;Carson Jian,&lt;BR /&gt;If this post &lt;EM&gt;&lt;STRONG&gt;helps&lt;/STRONG&gt;&lt;/EM&gt;, then please consider &lt;EM&gt;&lt;STRONG&gt;Accept it as the solution&lt;/STRONG&gt;&lt;/EM&gt; to help the other members find it more quickly.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Apr 2024 08:59:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-difference-between-values-of-two-years-in-the-same/m-p/3853031#M150533</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-04-19T08:59:30Z</dc:date>
    </item>
  </channel>
</rss>

