<?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: A Measure That Tracks changes in data over a year in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/A-Measure-That-Tracks-changes-in-data-over-a-year/m-p/3723416#M144998</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="695985" data-lia-user-login="Toora" class="lia-mention lia-mention-user"&gt;Toora&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;try something like this as a new calculated column:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;branch_change = 
VAR prev_date = 
    MINX( 
        TOPN( 
            1, 
            FILTER( your_table, your_table[Customer Code] = EARLIER ( your_table[Customer Code] ) &amp;amp;&amp;amp; your_table[Date] &amp;lt; EARLIER( your_table[Date] ) ),
            your_table[Date], 
            DESC
        ),
        your_table[Date]
    )
VAR prev_branch = 
    LOOKUPVALUE( your_table[Branch_Code], your_table[Date], prev_date )
VAR change =
    SWITCH( TRUE(),
        prev_branch = BLANK(), BLANK(),
        prev_branch &amp;lt;&amp;gt; your_table[Branch_Code], 1
    )
RETURN change&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Remeber replacing "your_table" with your actual table name.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If this post helped you, please consider marking it as solution, thank you!&lt;BR /&gt;&lt;BR /&gt;Cheers&lt;/P&gt;&lt;P&gt;Tim&lt;/P&gt;</description>
    <pubDate>Mon, 26 Feb 2024 09:22:18 GMT</pubDate>
    <dc:creator>timalbers</dc:creator>
    <dc:date>2024-02-26T09:22:18Z</dc:date>
    <item>
      <title>A Measure That Tracks changes in data over a year</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/A-Measure-That-Tracks-changes-in-data-over-a-year/m-p/3723253#M144991</link>
      <description>&lt;P&gt;Hi, I'm trying to come up with an expression that captures when a customer changes branch. See table below which reports on when customers made a visit. Basically I need the measure will return "1" for customer Z2225 as they moved branch&lt;/P&gt;&lt;P&gt;Date&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Customer Code&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Branch_Code&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;01/01/2022&lt;/TD&gt;&lt;TD&gt;L55&lt;/TD&gt;&lt;TD&gt;LIM&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;02/01/2022&lt;/TD&gt;&lt;TD&gt;A11&lt;/TD&gt;&lt;TD&gt;BEL&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;03/01/2022&lt;/TD&gt;&lt;TD&gt;A55&lt;/TD&gt;&lt;TD&gt;BEL&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;04/01/2022&lt;/TD&gt;&lt;TD&gt;552135051&lt;/TD&gt;&lt;TD&gt;LIM&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;05/01/2022&lt;/TD&gt;&lt;TD&gt;Z2225&lt;/TD&gt;&lt;TD&gt;BEL&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;06/01/2023&lt;/TD&gt;&lt;TD&gt;Z2225&lt;/TD&gt;&lt;TD&gt;LIM&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;07/01/2023&lt;/TD&gt;&lt;TD&gt;s22&lt;/TD&gt;&lt;TD&gt;BEL&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;08/01/2023&lt;/TD&gt;&lt;TD&gt;d22&lt;/TD&gt;&lt;TD&gt;BEL&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Mon, 26 Feb 2024 08:21:21 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/A-Measure-That-Tracks-changes-in-data-over-a-year/m-p/3723253#M144991</guid>
      <dc:creator>Toora</dc:creator>
      <dc:date>2024-02-26T08:21:21Z</dc:date>
    </item>
    <item>
      <title>Re: A Measure That Tracks changes in data over a year</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/A-Measure-That-Tracks-changes-in-data-over-a-year/m-p/3723416#M144998</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="695985" data-lia-user-login="Toora" class="lia-mention lia-mention-user"&gt;Toora&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;try something like this as a new calculated column:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;branch_change = 
VAR prev_date = 
    MINX( 
        TOPN( 
            1, 
            FILTER( your_table, your_table[Customer Code] = EARLIER ( your_table[Customer Code] ) &amp;amp;&amp;amp; your_table[Date] &amp;lt; EARLIER( your_table[Date] ) ),
            your_table[Date], 
            DESC
        ),
        your_table[Date]
    )
VAR prev_branch = 
    LOOKUPVALUE( your_table[Branch_Code], your_table[Date], prev_date )
VAR change =
    SWITCH( TRUE(),
        prev_branch = BLANK(), BLANK(),
        prev_branch &amp;lt;&amp;gt; your_table[Branch_Code], 1
    )
RETURN change&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Remeber replacing "your_table" with your actual table name.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If this post helped you, please consider marking it as solution, thank you!&lt;BR /&gt;&lt;BR /&gt;Cheers&lt;/P&gt;&lt;P&gt;Tim&lt;/P&gt;</description>
      <pubDate>Mon, 26 Feb 2024 09:22:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/A-Measure-That-Tracks-changes-in-data-over-a-year/m-p/3723416#M144998</guid>
      <dc:creator>timalbers</dc:creator>
      <dc:date>2024-02-26T09:22:18Z</dc:date>
    </item>
    <item>
      <title>Re: A Measure That Tracks changes in data over a year</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/A-Measure-That-Tracks-changes-in-data-over-a-year/m-p/3726054#M145142</link>
      <description>&lt;P&gt;Hi&amp;nbsp; &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="695985" data-lia-user-login="Toora" class="lia-mention lia-mention-user"&gt;Toora&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here are the steps you can follow：&lt;/P&gt;
&lt;P&gt;1. Create measure.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Measure =
var _count=COUNTX(FILTER(ALL('Table'),'Table'[Customer Code]=MAX('Table'[Customer Code])),[Branch_Code])
var _maxdate=MAXX(FILTER(ALL('Table'),'Table'[Customer Code]=MAX('Table'[Customer Code])),[Date])
var _mindate=MAXX(FILTER(ALL('Table'),'Table'[Customer Code]=MAX('Table'[Customer Code])&amp;amp;&amp;amp;'Table'[Date]&amp;lt;_maxdate),[Date])
var _newbranch=MAXX(FILTER(ALL('Table'),'Table'[Customer Code]=MAX('Table'[Customer Code])&amp;amp;&amp;amp;'Table'[Date]=_maxdate),[Branch_Code])
var _oldbranch=MAXX(FILTER(ALL('Table'),'Table'[Customer Code]=MAX('Table'[Customer Code])&amp;amp;&amp;amp;'Table'[Date]=_mindate),[Branch_Code])
return
IF(
  _count&amp;gt;1&amp;amp;&amp;amp;  MAX('Table'[Date])=_maxdate&amp;amp;&amp;amp;_newbranch&amp;lt;&amp;gt;_oldbranch,1,0)&lt;/LI-CODE&gt;
&lt;P&gt;2. 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;Best Regards,&lt;/P&gt;
&lt;P&gt;Liu Yang&lt;/P&gt;
&lt;P&gt;If this post &lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider &lt;EM&gt;Accept it as the solution&lt;/EM&gt; to help the other members find it more quickly&lt;/P&gt;</description>
      <pubDate>Tue, 27 Feb 2024 05:29:34 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/A-Measure-That-Tracks-changes-in-data-over-a-year/m-p/3726054#M145142</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-02-27T05:29:34Z</dc:date>
    </item>
  </channel>
</rss>

