<?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 Previous Period Pattern, inconsistent results in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-Period-Pattern-inconsistent-results/m-p/4121242#M163624</link>
    <description>&lt;P&gt;I have two fact tables joined to the same (well formed) date Table, both on 'Date'[Date].&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In fact table 1 I'm using the following measure to calculate previous period for a sumed value:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;Previous Period Logins = 
SWITCH(
    TRUE(),
    ISINSCOPE( 'Date'[Date] ),
        CALCULATE( [Logins (sum)], DATEADD( 'Date'[Date], -1, DAY )),
    ISINSCOPE( 'Date'[Fiscal Month] ),
        CALCULATE( [Logins (sum)], DATEADD( 'Date'[Date], -1, MONTH )),
    ISINSCOPE( 'Date'[Fiscal Quarter] ),
        CALCULATE( [Logins (sum)], DATEADD( 'Date'[Date], -1, QUARTER )),
    ISINSCOPE( 'Date'[Fiscal Year] ),
        CALCULATE( [Logins (sum)], DATEADD( 'Date'[Date], -1, YEAR ))
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I applied the same pattern to fact table 2, again a SUM on a value, and instead of returning the previous period, it returns the same value as the 'current' period. I'm super confused as I've checked backwards and forwards and there are no 'differences' other than a different fact table and different facts.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;Design Area Avg Previous Period = 
VAR _area = SUM('Monthly Project Data'[Design Area Avg])
VAR _result =
    SWITCH(
        TRUE(),
        ISINSCOPE( 'Date'[Date] ),
            CALCULATE( _area , DATEADD( 'Date'[Date], -1, DAY )),
        ISINSCOPE( 'Date'[Fiscal Month] ),
            CALCULATE( _area , DATEADD( 'Date'[Date], -1, MONTH )),
        ISINSCOPE( 'Date'[Fiscal Quarter] ),
            CALCULATE( _area , DATEADD( 'Date'[Date], -1, QUARTER )),
        ISINSCOPE( 'Date'[Fiscal Year] ),
            CALCULATE( _area , DATEADD( 'Date'[Date], -1, YEAR ))
    )
RETURN
_result&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I guess the only other thing worth noting is that both facts have monthly granularity, not daily, but that should not matter, as I'm not trying to visualize the data at daily granularity anyway.&lt;BR /&gt;&lt;BR /&gt;Looking for advice on what else I should be considering as to why I'm getting inconsistent results. What am I possibly missing or forgetting about?&lt;/P&gt;</description>
    <pubDate>Tue, 27 Aug 2024 17:24:17 GMT</pubDate>
    <dc:creator>rpiboy_1</dc:creator>
    <dc:date>2024-08-27T17:24:17Z</dc:date>
    <item>
      <title>Previous Period Pattern, inconsistent results</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-Period-Pattern-inconsistent-results/m-p/4121242#M163624</link>
      <description>&lt;P&gt;I have two fact tables joined to the same (well formed) date Table, both on 'Date'[Date].&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In fact table 1 I'm using the following measure to calculate previous period for a sumed value:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;Previous Period Logins = 
SWITCH(
    TRUE(),
    ISINSCOPE( 'Date'[Date] ),
        CALCULATE( [Logins (sum)], DATEADD( 'Date'[Date], -1, DAY )),
    ISINSCOPE( 'Date'[Fiscal Month] ),
        CALCULATE( [Logins (sum)], DATEADD( 'Date'[Date], -1, MONTH )),
    ISINSCOPE( 'Date'[Fiscal Quarter] ),
        CALCULATE( [Logins (sum)], DATEADD( 'Date'[Date], -1, QUARTER )),
    ISINSCOPE( 'Date'[Fiscal Year] ),
        CALCULATE( [Logins (sum)], DATEADD( 'Date'[Date], -1, YEAR ))
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I applied the same pattern to fact table 2, again a SUM on a value, and instead of returning the previous period, it returns the same value as the 'current' period. I'm super confused as I've checked backwards and forwards and there are no 'differences' other than a different fact table and different facts.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;Design Area Avg Previous Period = 
VAR _area = SUM('Monthly Project Data'[Design Area Avg])
VAR _result =
    SWITCH(
        TRUE(),
        ISINSCOPE( 'Date'[Date] ),
            CALCULATE( _area , DATEADD( 'Date'[Date], -1, DAY )),
        ISINSCOPE( 'Date'[Fiscal Month] ),
            CALCULATE( _area , DATEADD( 'Date'[Date], -1, MONTH )),
        ISINSCOPE( 'Date'[Fiscal Quarter] ),
            CALCULATE( _area , DATEADD( 'Date'[Date], -1, QUARTER )),
        ISINSCOPE( 'Date'[Fiscal Year] ),
            CALCULATE( _area , DATEADD( 'Date'[Date], -1, YEAR ))
    )
RETURN
_result&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I guess the only other thing worth noting is that both facts have monthly granularity, not daily, but that should not matter, as I'm not trying to visualize the data at daily granularity anyway.&lt;BR /&gt;&lt;BR /&gt;Looking for advice on what else I should be considering as to why I'm getting inconsistent results. What am I possibly missing or forgetting about?&lt;/P&gt;</description>
      <pubDate>Tue, 27 Aug 2024 17:24:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-Period-Pattern-inconsistent-results/m-p/4121242#M163624</guid>
      <dc:creator>rpiboy_1</dc:creator>
      <dc:date>2024-08-27T17:24:17Z</dc:date>
    </item>
    <item>
      <title>Re: Previous Period Pattern, inconsistent results</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-Period-Pattern-inconsistent-results/m-p/4121286#M163627</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="452756" data-lia-user-login="rpiboy_1" class="lia-mention lia-mention-user"&gt;rpiboy_1&lt;/a&gt;&amp;nbsp;Variables (VAR) despite their name are constants and once calculated remain the same value regardless of anything you might try to do. So, that's the reason for the results you are getting.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Aug 2024 17:45:55 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-Period-Pattern-inconsistent-results/m-p/4121286#M163627</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2024-08-27T17:45:55Z</dc:date>
    </item>
    <item>
      <title>Re: Previous Period Pattern, inconsistent results</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-Period-Pattern-inconsistent-results/m-p/4121963#M163664</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="452756" data-lia-user-login="rpiboy_1" class="lia-mention lia-mention-user"&gt;rpiboy_1&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I’d like to acknowledge the valuable input provided by Greg_Deckler&amp;nbsp;. Their initial ideas were instrumental in guiding my approach. However, I noticed that further details were needed to fully understand the issue.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can refer to my example and make appropriate changes to your measure.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Measure = 
VAR _result = 
    SWITCH(
        TRUE(),
        ISINSCOPE( 'Date'[Date].[Day] ),
            CALCULATE( SUM('financials'[ Sales]), DATEADD( 'Date'[Date], -1, DAY )),
        ISINSCOPE( 'Date'[Date].[Month] ),
            CALCULATE( SUM('financials'[ Sales]) , DATEADD( 'Date'[Date], -1, MONTH )),
        ISINSCOPE( 'Date'[Date].[Quarter] ),
            CALCULATE( SUM('financials'[ Sales]) , DATEADD( 'Date'[Date], -1, QUARTER )),
        ISINSCOPE( 'Date'[Date].[Year]),
            CALCULATE( SUM('financials'[ Sales]) , DATEADD( 'Date'[Date], -1, YEAR ))
    )
RETURN
_result&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;If your Current Period does not refer to this, please clarify in a follow-up reply.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Clara Gong&lt;/P&gt;
&lt;P&gt;If there is any post&amp;nbsp;&lt;STRONG&gt;&lt;I&gt;helps&lt;/I&gt;&lt;/STRONG&gt;, then please consider&amp;nbsp;&lt;STRONG&gt;&lt;I&gt;Accept it as the solution&lt;/I&gt;&lt;/STRONG&gt;&amp;nbsp;&amp;nbsp;to help the other members find it more quickly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Aug 2024 05:37:45 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-Period-Pattern-inconsistent-results/m-p/4121963#M163664</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-08-28T05:37:45Z</dc:date>
    </item>
    <item>
      <title>Re: Previous Period Pattern, inconsistent results</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-Period-Pattern-inconsistent-results/m-p/4122792#M163691</link>
      <description>&lt;P&gt;Ugh... yeah, I've read that before, but I don't do this work day in and day out, so hard to remember all of the 'details'. Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 28 Aug 2024 12:37:33 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-Period-Pattern-inconsistent-results/m-p/4122792#M163691</guid>
      <dc:creator>rpiboy_1</dc:creator>
      <dc:date>2024-08-28T12:37:33Z</dc:date>
    </item>
  </channel>
</rss>

