<?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 Need help in dax caulation for this week and last months same week sales in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-in-dax-caulation-for-this-week-and-last-months-same/m-p/2692486#M81113</link>
    <description>&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Date&lt;/TD&gt;&lt;TD&gt;Sales&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;10-Aug-2022&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;100&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;11-July-2022&lt;/TD&gt;&lt;TD&gt;60&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;08-July-2022&lt;/TD&gt;&lt;TD&gt;40&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;09-July-2022&lt;/TD&gt;&lt;TD&gt;22&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;09-Aug-2022&lt;/TD&gt;&lt;TD&gt;234&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;I have 2 column Date and Sales. I need to calculate below:&lt;/P&gt;&lt;P&gt;If today date in Aug 10 I need dax for:&lt;BR /&gt;1. This week sales-last month's same week sales&lt;BR /&gt;i.e sales from 8,9,10 minus sales from July 8,9,10&lt;/P&gt;&lt;P&gt;2. Similary today's sale minus last month's same day sale&lt;BR /&gt;i.e sale of Aug 10-sale of July 10&lt;/P&gt;</description>
    <pubDate>Wed, 10 Aug 2022 12:58:27 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2022-08-10T12:58:27Z</dc:date>
    <item>
      <title>Need help in dax caulation for this week and last months same week sales</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-in-dax-caulation-for-this-week-and-last-months-same/m-p/2692486#M81113</link>
      <description>&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Date&lt;/TD&gt;&lt;TD&gt;Sales&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;10-Aug-2022&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;100&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;11-July-2022&lt;/TD&gt;&lt;TD&gt;60&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;08-July-2022&lt;/TD&gt;&lt;TD&gt;40&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;09-July-2022&lt;/TD&gt;&lt;TD&gt;22&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;09-Aug-2022&lt;/TD&gt;&lt;TD&gt;234&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;I have 2 column Date and Sales. I need to calculate below:&lt;/P&gt;&lt;P&gt;If today date in Aug 10 I need dax for:&lt;BR /&gt;1. This week sales-last month's same week sales&lt;BR /&gt;i.e sales from 8,9,10 minus sales from July 8,9,10&lt;/P&gt;&lt;P&gt;2. Similary today's sale minus last month's same day sale&lt;BR /&gt;i.e sale of Aug 10-sale of July 10&lt;/P&gt;</description>
      <pubDate>Wed, 10 Aug 2022 12:58:27 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-in-dax-caulation-for-this-week-and-last-months-same/m-p/2692486#M81113</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-08-10T12:58:27Z</dc:date>
    </item>
    <item>
      <title>Re: Need help in dax caulation for this week and last months same week sales</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-in-dax-caulation-for-this-week-and-last-months-same/m-p/2692597#M81115</link>
      <description>&lt;P&gt;Hi there&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You probably thought it'd be easy as 1-2-3.... No, it's not.&lt;/P&gt;&lt;P&gt;Please read this article:&amp;nbsp;&lt;A href="https://www.sqlbi.com/articles/week-based-time-intelligence-in-dax/" target="_blank"&gt;Week-Based Time Intelligence in DAX - SQLBI&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Aug 2022 13:08:35 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-in-dax-caulation-for-this-week-and-last-months-same/m-p/2692597#M81115</guid>
      <dc:creator>daXtreme</dc:creator>
      <dc:date>2022-08-10T13:08:35Z</dc:date>
    </item>
    <item>
      <title>Re: Need help in dax caulation for this week and last months same week sales</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-in-dax-caulation-for-this-week-and-last-months-same/m-p/2692640#M81120</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I tried to create a sample pbix file like below.&lt;/P&gt;
&lt;P&gt;Please check the below picture and the attached pbix file.&lt;/P&gt;
&lt;P&gt;I hope the below can provide some ideas on how to create a solution for your dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&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;WTD sales vs previousmonth same dates sales: = 
VAR _wtdtable =
    FILTER (
        ALL ( 'Calendar' ),
        'Calendar'[Date] &amp;lt;= MAX ( 'Calendar'[Date] )
            &amp;amp;&amp;amp; 'Calendar'[Start of Week] = MAX ( 'Calendar'[Start of Week] )
    )
VAR _daynumberlist =
    SUMMARIZE ( _wtdtable, 'Calendar'[Day] )
VAR _previousmonthwtdtablestartdate =
    DATE ( IF (
        MAX ( 'Calendar'[Month] ) = 1,
        MAX ( 'Calendar'[Year] ) - 1,
        MAX ( 'Calendar'[Year] )
    ), IF ( MAX ( 'Calendar'[Month] ) = 1, 12, MAX ( 'Calendar'[Month] ) - 1 ), DAY ( MINX ( _wtdtable, 'Calendar'[Date] ) ) )
VAR _previousmonthwtdtablefinishdate =
    DATE ( IF (
        MAX ( 'Calendar'[Month] ) = 1,
        MAX ( 'Calendar'[Year] ) - 1,
        MAX ( 'Calendar'[Year] )
    ), IF ( MAX ( 'Calendar'[Month] ) = 1, 12, MAX ( 'Calendar'[Month] ) - 1 ), DAY ( MAXX ( _wtdtable, 'Calendar'[Date] ) ) )
VAR _currentmonthwtd =
    CALCULATE ( [Sales measure:], _wtdtable )
VAR _previousmonthexpected =
    CALCULATE (
        [Sales measure:],
        DATESBETWEEN (
            'Calendar'[Date],
            _previousmonthwtdtablestartdate,
            _previousmonthwtdtablefinishdate
        )
    )
RETURN
    IF (
        NOT ISBLANK ( CALCULATE ( [Sales measure:], PREVIOUSMONTH ( 'Calendar'[Date] ) ) ),
        _currentmonthwtd - _previousmonthexpected
    )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;sales vs last month same day sales: =
IF (
    NOT ISBLANK (
        CALCULATE ( [Sales measure:], DATEADD ( 'Calendar'[Date], -1, MONTH ) )
    ),
    [Sales measure:]
        - CALCULATE ( [Sales measure:], DATEADD ( 'Calendar'[Date], -1, MONTH ) )
)
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Aug 2022 13:36:52 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-in-dax-caulation-for-this-week-and-last-months-same/m-p/2692640#M81120</guid>
      <dc:creator>Jihwan_Kim</dc:creator>
      <dc:date>2022-08-10T13:36:52Z</dc:date>
    </item>
    <item>
      <title>Re: Need help in dax caulation for this week and last months same week sales</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-in-dax-caulation-for-this-week-and-last-months-same/m-p/2708175#M82183</link>
      <description>&lt;P&gt;Hi&amp;nbsp; Anonymous&lt;/LI-USER&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;I created some data:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Here are the steps you can follow：&lt;/P&gt;
&lt;P&gt;1. Create calculated column.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Year = YEAR('Table'[Date])&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;Month = MONTH('Table'[Date])&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;Week = WEEKNUM('Table'[Date],1)&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;weeknumber =
RANKX(FILTER(ALL('Table'),
'Table'[Year]=EARLIER('Table'[Year])&amp;amp;&amp;amp;'Table'[Month]=EARLIER('Table'[Month])),[Week],,ASC,Dense)&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;2. Create measure.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Dax1 =
var _today=TODAY()
var _week=
MAXX(FILTER(ALL('Table'),'Table'[Date]=_today),[weeknumber])
var _weeksales=
SUMX(FILTER(ALL('Table'),'Table'[Month]=MONTH(_today)&amp;amp;&amp;amp;'Table'[weeknumber]=_week),[Amount])
var _lastmonth=
SUMX(FILTER(ALL('Table'),'Table'[Month]=MONTH(_today)-1&amp;amp;&amp;amp;'Table'[weeknumber]=_week),[Amount])
return
_weeksales - _lastmonth&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;Dax2 =
var _today=TODAY()
var _todaysalse=
SUMX(FILTER(ALL('Table'),'Table'[Date]=_today),[Amount])
var _lastmonthsameday=
SUMX(FILTER(ALL('Table'),'Table'[Date]=DATE(YEAR(_today),MONTH(_today)-1,DAY(_today))),[Amount])
return
_todaysalse - _lastmonthsameday&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;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>Thu, 18 Aug 2022 00:53:11 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-in-dax-caulation-for-this-week-and-last-months-same/m-p/2708175#M82183</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-08-18T00:53:11Z</dc:date>
    </item>
  </channel>
</rss>

