<?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 Calculating change between periods in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-change-between-periods/m-p/2676423#M79997</link>
    <description>&lt;P&gt;Hi there, I have some data that looks like this:&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;Period&lt;/TD&gt;&lt;TD&gt;Beginining Population&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Ice Age&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Renaissance&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;50&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Industrial Revolution&lt;/TD&gt;&lt;TD&gt;200&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My end goal is to calculate the change between periods but I'm struggling to figure out what the correct columns/measures are to calculate that:&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;Period&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF0000"&gt;Ending Period&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;Beginining Population&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF0000"&gt;Ending Population&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF0000"&gt;Change&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Ice Age&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF0000"&gt;Renaissance&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF0000"&gt;50&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF0000"&gt;49&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Renaissance&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF0000"&gt;Industrial Revolution&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;50&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF0000"&gt;200&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF0000"&gt;150&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Industrial Revolution&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF0000"&gt;NA&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;200&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF0000"&gt;NA&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF0000"&gt;NA&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What would the simplest way to calculate the above? Thanks so much!&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 02 Aug 2022 19:01:42 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2022-08-02T19:01:42Z</dc:date>
    <item>
      <title>Calculating change between periods</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-change-between-periods/m-p/2676423#M79997</link>
      <description>&lt;P&gt;Hi there, I have some data that looks like this:&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;Period&lt;/TD&gt;&lt;TD&gt;Beginining Population&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Ice Age&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Renaissance&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;50&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Industrial Revolution&lt;/TD&gt;&lt;TD&gt;200&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My end goal is to calculate the change between periods but I'm struggling to figure out what the correct columns/measures are to calculate that:&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;Period&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF0000"&gt;Ending Period&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;Beginining Population&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF0000"&gt;Ending Population&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF0000"&gt;Change&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Ice Age&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF0000"&gt;Renaissance&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF0000"&gt;50&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF0000"&gt;49&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Renaissance&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF0000"&gt;Industrial Revolution&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;50&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF0000"&gt;200&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF0000"&gt;150&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Industrial Revolution&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF0000"&gt;NA&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;200&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF0000"&gt;NA&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF0000"&gt;NA&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What would the simplest way to calculate the above? Thanks so much!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Aug 2022 19:01:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-change-between-periods/m-p/2676423#M79997</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-08-02T19:01:42Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating change between periods</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-change-between-periods/m-p/2676492#M80003</link>
      <description>&lt;P&gt;Hey,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is best done in Power Query.&amp;nbsp;Here is the code for the query that you can place in the Advanced Editor. The code is exactly based on your example above.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8kxOVXBMT1XSUTJUitWJVgpKzUvMLC5OzEsGiZkagAU981JKi0uKMhNzFIJSy/JzSksy8/OA0kYGQPlYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Period = _t, #"Beginning Population" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Period", type text}, {"Beginning Population", Int64.Type}}),
    #"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 1, 1, Int64.Type),
    #"Added Custom" = Table.AddColumn(#"Added Index", "NextIndex", each [Index] + 1, Int64.Type),
    #"Merged Queries" = Table.NestedJoin(#"Added Custom", {"NextIndex"}, #"Added Custom", {"Index"}, "Added Custom", JoinKind.LeftOuter),
    #"Expanded Added Custom" = Table.ExpandTableColumn(#"Merged Queries", "Added Custom", {"Period", "Beginning Population"}, {"Ending Period", "Ending Population"}),
    #"Inserted Subtraction" = Table.AddColumn(#"Expanded Added Custom", "Population Change", each [Ending Population] - [Beginning Population], Int64.Type),
    #"Removed Other Columns" = Table.SelectColumns(#"Inserted Subtraction",{"Period", "Beginning Population", "Ending Period", "Ending Population", "Population Change"}),
    #"Reordered Columns" = Table.ReorderColumns(#"Removed Other Columns",{"Period", "Ending Period", "Beginning Population", "Ending Population", "Population Change"})
in
    #"Reordered Columns"&lt;/LI-CODE&gt;&lt;P&gt;Please let me know if you have any questions.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Aug 2022 20:02:27 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-change-between-periods/m-p/2676492#M80003</guid>
      <dc:creator>Barthel</dc:creator>
      <dc:date>2022-08-02T20:02:27Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating change between periods</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-change-between-periods/m-p/2688707#M80884</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Provide another way of thinking:&lt;/P&gt;&lt;P&gt;1.&amp;nbsp;First, create a new Index column in Power Query Eidtor to indicate the order of Periods.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;2.&amp;nbsp;Then create 3 measures:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Ending Period = 
VAR _index =
    MAX ( 'Table'[Index] ) + 1
VAR _period =
    MAXX (
        FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Index] = _index ),
        'Table'[Period]
    )
VAR _result =
    IF ( _period &amp;lt;&amp;gt; BLANK (), _period, "NA" )
RETURN
    _result&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;Ending Population = 
VAR _index =
    MAX ( 'Table'[Index] ) + 1
VAR _population =
    MAXX (
        FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Index] = _index ),
        'Table'[Beginining Population]
    )
VAR _result =
    IF ( _population &amp;lt;&amp;gt; BLANK (), _population, "NA" )
RETURN
    _result&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;Change = 
VAR _index =
    MAX ( 'Table'[Index] ) + 1
VAR _beg_population = 
MAX('Table'[Beginining Population])
VAR _population =
    MAXX (
        FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Index] = _index ),
        'Table'[Beginining Population]
    )
VAR _change = _population - _beg_population
VAR _result =
    IF ( _population &amp;lt;&amp;gt; BLANK (), _change, "NA" )
RETURN
    _result&lt;/LI-CODE&gt;&lt;P&gt;3.Result:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Best Regards,&lt;/SPAN&gt;&lt;BR /&gt;changqing&lt;/P&gt;</description>
      <pubDate>Tue, 09 Aug 2022 06:09:51 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-change-between-periods/m-p/2688707#M80884</guid>
      <dc:creator>changqing</dc:creator>
      <dc:date>2022-08-09T06:09:51Z</dc:date>
    </item>
  </channel>
</rss>

