<?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 Show Previous month value based on month order. in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Show-Previous-month-value-based-on-month-order/m-p/3336576#M125143</link>
    <description>&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;SPAN&gt;I would like to ask about the DAX I saw online (see script below). The context is that I'm having trouble showing the previous month's because the data have gaps, these are the months with no data on the dataset (Mar 2022, May2022, &amp;amp; Jun 2022). I would like to ask for help to make the value show based on the month order not based on the date with data on dataset. I will attach the snips below and also the script I found. Thanks.&lt;BR /&gt;Target Output: ($1535) should reflect on the second column of Mar 2022 not in Apr 2022&lt;BR /&gt;&lt;img /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;P&gt;1st col.= Report Month&lt;/P&gt;&lt;P&gt;2nd col.= Current Month Value&lt;/P&gt;&lt;P&gt;3rd col.= Previous Month Value&amp;nbsp;&lt;/P&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;This is the code&lt;/P&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;previous result =
var period_context = MAX (data [period])

var previous_period =
CALCULATE(
   MAX (data [period]),
   FILTER(
      ALL (data [period]),
      data [period] &amp;lt;period_context &amp;amp;&amp;amp;
      SUM (data [value]) &amp;lt;&amp;gt; BLANK ()
   )
)

var previous_month_value =
CALCULATE(
   SUM (data [value]),
   FILTER(
      ALL (data [period]),
      data [period] = previous_period
   )
)

Return
if(
   ISINSCOPE (data [period]),
   previous_month_value
)&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Tue, 18 Jul 2023 13:30:29 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2023-07-18T13:30:29Z</dc:date>
    <item>
      <title>Show Previous month value based on month order.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Show-Previous-month-value-based-on-month-order/m-p/3336576#M125143</link>
      <description>&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;SPAN&gt;I would like to ask about the DAX I saw online (see script below). The context is that I'm having trouble showing the previous month's because the data have gaps, these are the months with no data on the dataset (Mar 2022, May2022, &amp;amp; Jun 2022). I would like to ask for help to make the value show based on the month order not based on the date with data on dataset. I will attach the snips below and also the script I found. Thanks.&lt;BR /&gt;Target Output: ($1535) should reflect on the second column of Mar 2022 not in Apr 2022&lt;BR /&gt;&lt;img /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;P&gt;1st col.= Report Month&lt;/P&gt;&lt;P&gt;2nd col.= Current Month Value&lt;/P&gt;&lt;P&gt;3rd col.= Previous Month Value&amp;nbsp;&lt;/P&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;This is the code&lt;/P&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;previous result =
var period_context = MAX (data [period])

var previous_period =
CALCULATE(
   MAX (data [period]),
   FILTER(
      ALL (data [period]),
      data [period] &amp;lt;period_context &amp;amp;&amp;amp;
      SUM (data [value]) &amp;lt;&amp;gt; BLANK ()
   )
)

var previous_month_value =
CALCULATE(
   SUM (data [value]),
   FILTER(
      ALL (data [period]),
      data [period] = previous_period
   )
)

Return
if(
   ISINSCOPE (data [period]),
   previous_month_value
)&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 18 Jul 2023 13:30:29 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Show-Previous-month-value-based-on-month-order/m-p/3336576#M125143</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-07-18T13:30:29Z</dc:date>
    </item>
    <item>
      <title>Re: Show Previous month value based on month order.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Show-Previous-month-value-based-on-month-order/m-p/3339699#M125328</link>
      <description>&lt;P&gt;Add a calendar table to your data model.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jul 2023 00:35:52 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Show-Previous-month-value-based-on-month-order/m-p/3339699#M125328</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2023-07-20T00:35:52Z</dc:date>
    </item>
  </channel>
</rss>

