<?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: Identify rows where plan changed by ID and sameperiodlastyear in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Identify-rows-where-plan-changed-by-ID-and-sameperiodlastyear/m-p/4139991#M164502</link>
    <description>&lt;P&gt;Hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="379433" data-lia-user-login="Marvhall" class="lia-mention lia-mention-user"&gt;Marvhall&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Based on my testing, please &lt;SPAN&gt;try the following methods:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;1.Create the&lt;/SPAN&gt;&lt;SPAN&gt; new column to filter the changed plan.&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;SamePeriodLastYear = 
       CALCULATE(
           MAX('Table A'[Plan]),
           FILTER(
               'Table A',
               ('Table A'[ID] = EARLIER('Table A'[ID]) &amp;amp;&amp;amp;
               YEAR('Table A'[Date]) = YEAR(EARLIER('Table A'[Date])) - 1 &amp;amp;&amp;amp;
               MONTH('Table A'[Date]) = MONTH(EARLIER('Table A'[Date])) &amp;amp;&amp;amp; EARLIER('Table A'[Plan]) = "A")
           )
       )&lt;/LI-CODE&gt;
&lt;P&gt;&lt;SPAN&gt;2.Create the new &lt;/SPAN&gt;&lt;SPAN&gt;column to filter the rows.&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Plan changed = 
var _sameperiod = VALUES('Table A'[SamePeriodLastYear])
var _date = SELECTEDVALUE('Table'[Date])
RETURN
IF(
    ('Table A'[Plan] = "A" &amp;amp;&amp;amp; 'Table A'[Date] = DATE(2024, 7 ,1)) || ('Table A'[Plan] IN _sameperiod &amp;amp;&amp;amp; 'Table A'[Date] = DATE(2023,7,1)),
    1,
    0
)
&lt;/LI-CODE&gt;
&lt;P&gt;&lt;SPAN&gt;3.&lt;/SPAN&gt;&lt;SPAN&gt;Create new table.&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Table B = FILTER('Table A', 'Table A'[Plan changed] = 1)&lt;/LI-CODE&gt;
&lt;P&gt;&lt;SPAN&gt;4.Table B is shown below.&lt;/SPAN&gt;&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;/P&gt;
&lt;P&gt;Wisdom Wu&lt;/P&gt;
&lt;P&gt;&lt;SPAN&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;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 09 Sep 2024 06:43:25 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2024-09-09T06:43:25Z</dc:date>
    <item>
      <title>Identify rows where plan changed by ID and sameperiodlastyear</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Identify-rows-where-plan-changed-by-ID-and-sameperiodlastyear/m-p/4131758#M164116</link>
      <description>&lt;P&gt;Good afternoon,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to identify the rows that have the same ID, plan A in the later year and a different plan sameperiodlastyear.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is an example:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;Table A (what I have) is a comprehensive list of all IDs, plans, and dates. I need Table B where I only get the two (if exist) ID where the later date was plan A and a different plan sameperiodlastyear.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried several formulas and can get close but it won't list only the two rows I need per ID (if exist under the above conditions).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Sep 2024 17:19:09 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Identify-rows-where-plan-changed-by-ID-and-sameperiodlastyear/m-p/4131758#M164116</guid>
      <dc:creator>Marvhall</dc:creator>
      <dc:date>2024-09-03T17:19:09Z</dc:date>
    </item>
    <item>
      <title>Re: Identify rows where plan changed by ID and sameperiodlastyear</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Identify-rows-where-plan-changed-by-ID-and-sameperiodlastyear/m-p/4131853#M164125</link>
      <description>&lt;P&gt;Hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="379433" data-lia-user-login="Marvhall" class="lia-mention lia-mention-user"&gt;Marvhall&lt;/a&gt;, give calculated table a try, and if you encounter any issues, let me know.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;create a calculated table:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;TableB = 
VAR CurrentPeriod = 
    SELECTCOLUMNS(
        FILTER('TableA', 'TableA'[Date] = DATE(2024, 7, 1)),
        "ID", 'TableA'[ID],
        "Plan", 'TableA'[Plan],
        "Date", 'TableA'[Date]
    )

VAR PreviousPeriod = 
    SELECTCOLUMNS(
        FILTER('TableA', 'TableA'[Date] = DATE(2023, 7, 1)),
        "ID", 'TableA'[ID],
        "Plan", 'TableA'[Plan],
        "Date", 'TableA'[Date]
    )

RETURN
    FILTER(
        NATURALINNERJOIN(CurrentPeriod, PreviousPeriod),
        CurrentPeriod[Plan] = "A" &amp;amp;&amp;amp;
        PreviousPeriod[Plan] &amp;lt;&amp;gt; "A"
    )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P align="center"&gt;&lt;FONT face="verdana,geneva"&gt;&lt;FONT color="#99CC00"&gt;&lt;STRONG&gt;Did I answer your question?&lt;/STRONG&gt;&lt;/FONT&gt; &lt;FONT color="#99CC00"&gt;&lt;STRONG&gt;If so, please mark my post as the solution! &lt;span class="lia-unicode-emoji" title=":heavy_check_mark:"&gt;✔️&lt;/span&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="verdana,geneva"&gt;&lt;FONT color="#99CC00"&gt;&lt;STRONG&gt;Your Kudos are much appreciated!&lt;/STRONG&gt;&lt;/FONT&gt; &lt;FONT color="#99CC00"&gt;&lt;STRONG&gt;Proud to be a Solution Supplier!&lt;/STRONG&gt;&lt;/FONT&gt; &lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Sep 2024 19:13:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Identify-rows-where-plan-changed-by-ID-and-sameperiodlastyear/m-p/4131853#M164125</guid>
      <dc:creator>ahadkarimi</dc:creator>
      <dc:date>2024-09-03T19:13:26Z</dc:date>
    </item>
    <item>
      <title>Re: Identify rows where plan changed by ID and sameperiodlastyear</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Identify-rows-where-plan-changed-by-ID-and-sameperiodlastyear/m-p/4131871#M164128</link>
      <description>&lt;P&gt;Thank you. I get the error:&amp;nbsp;The expression refers to multiple columns. Multiple columns cannot be converted to a scalar value. Same issue I ran into before. I tried using sumx or another aggregate but that didn't work either.&lt;/P&gt;</description>
      <pubDate>Tue, 03 Sep 2024 19:27:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Identify-rows-where-plan-changed-by-ID-and-sameperiodlastyear/m-p/4131871#M164128</guid>
      <dc:creator>Marvhall</dc:creator>
      <dc:date>2024-09-03T19:27:42Z</dc:date>
    </item>
    <item>
      <title>Re: Identify rows where plan changed by ID and sameperiodlastyear</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Identify-rows-where-plan-changed-by-ID-and-sameperiodlastyear/m-p/4139991#M164502</link>
      <description>&lt;P&gt;Hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="379433" data-lia-user-login="Marvhall" class="lia-mention lia-mention-user"&gt;Marvhall&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Based on my testing, please &lt;SPAN&gt;try the following methods:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;1.Create the&lt;/SPAN&gt;&lt;SPAN&gt; new column to filter the changed plan.&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;SamePeriodLastYear = 
       CALCULATE(
           MAX('Table A'[Plan]),
           FILTER(
               'Table A',
               ('Table A'[ID] = EARLIER('Table A'[ID]) &amp;amp;&amp;amp;
               YEAR('Table A'[Date]) = YEAR(EARLIER('Table A'[Date])) - 1 &amp;amp;&amp;amp;
               MONTH('Table A'[Date]) = MONTH(EARLIER('Table A'[Date])) &amp;amp;&amp;amp; EARLIER('Table A'[Plan]) = "A")
           )
       )&lt;/LI-CODE&gt;
&lt;P&gt;&lt;SPAN&gt;2.Create the new &lt;/SPAN&gt;&lt;SPAN&gt;column to filter the rows.&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Plan changed = 
var _sameperiod = VALUES('Table A'[SamePeriodLastYear])
var _date = SELECTEDVALUE('Table'[Date])
RETURN
IF(
    ('Table A'[Plan] = "A" &amp;amp;&amp;amp; 'Table A'[Date] = DATE(2024, 7 ,1)) || ('Table A'[Plan] IN _sameperiod &amp;amp;&amp;amp; 'Table A'[Date] = DATE(2023,7,1)),
    1,
    0
)
&lt;/LI-CODE&gt;
&lt;P&gt;&lt;SPAN&gt;3.&lt;/SPAN&gt;&lt;SPAN&gt;Create new table.&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Table B = FILTER('Table A', 'Table A'[Plan changed] = 1)&lt;/LI-CODE&gt;
&lt;P&gt;&lt;SPAN&gt;4.Table B is shown below.&lt;/SPAN&gt;&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;/P&gt;
&lt;P&gt;Wisdom Wu&lt;/P&gt;
&lt;P&gt;&lt;SPAN&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;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Sep 2024 06:43:25 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Identify-rows-where-plan-changed-by-ID-and-sameperiodlastyear/m-p/4139991#M164502</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-09-09T06:43:25Z</dc:date>
    </item>
  </channel>
</rss>

