<?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: Calculate current month &amp;amp; previous month values in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-current-month-amp-previous-month-values/m-p/3546631#M136380</link>
    <description>&lt;P&gt;I was overthinking this&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt;. Used these calcs and then applied slicers for month &amp;amp; year on the graph&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Current Month Year = &lt;/SPAN&gt;&lt;SPAN&gt;CALCULATE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;SUM&lt;/SPAN&gt;&lt;SPAN&gt; (&lt;/SPAN&gt;&lt;SPAN&gt;table[count]&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&lt;SPAN&gt;Previous Month Year =&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;DIV&gt;&lt;SPAN&gt;CALCULATE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;SUM&lt;/SPAN&gt;&lt;SPAN&gt; (&lt;/SPAN&gt;&lt;SPAN&gt;table[count]&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;SAMEPERIODLASTYEAR&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'Date Table'[Date]&lt;/SPAN&gt;&lt;SPAN&gt;))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Wed, 22 Nov 2023 11:01:26 GMT</pubDate>
    <dc:creator>blowers</dc:creator>
    <dc:date>2023-11-22T11:01:26Z</dc:date>
    <item>
      <title>Calculate current month &amp; previous month values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-current-month-amp-previous-month-values/m-p/3535444#M135856</link>
      <description>&lt;P&gt;I have created the following calcs for current &amp;amp; previous months counts when joining to a date table, however they dont account for the year which is causing me issues. Is there a way to add year to these existing calcs?&lt;/P&gt;&lt;P&gt;My aim is to get current &amp;amp; previous months counts and then use a day field (1-31) to display these in a graph for comparison.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Current Month = CALCULATE(count(Table1[column]),FILTER('Date Table',MONTH('Date Table'[Date])=MONTH(now())))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Previous Month = var current_month= MONTH(TODAY()) return&lt;BR /&gt;CALCULATE(COUNT(Table1[column]),FILTER('Date Table',MONTH('Date Table'[Date])=current_month -1))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 15 Nov 2023 15:57:46 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-current-month-amp-previous-month-values/m-p/3535444#M135856</guid>
      <dc:creator>blowers</dc:creator>
      <dc:date>2023-11-15T15:57:46Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate current month &amp; previous month values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-current-month-amp-previous-month-values/m-p/3535537#M135859</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="634003" data-lia-user-login="blowers" class="lia-mention lia-mention-user"&gt;blowers&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;So for the understanding of this date, previous month in a way you did it:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;dates = 
VAR _today = TODAY ()
VAR _year = YEAR ( _today )
VAR _month = MONTH ( _today )
VAR _previousMonth = _month - 1
RETURN
    "This month-year: " &amp;amp; _year &amp;amp; " " &amp;amp; _month &amp;amp; " " &amp;amp; 
    "Previous month-year: " &amp;amp; _year &amp;amp; " " &amp;amp; _previousMonth&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Your date table can and I believe should contain columns like Month, Year, etc. It is easy to build in Power Query, DAX, etc. So you'll have something like this:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Current Month = 
VAR _today = TODAY ()
VAR _year = YEAR ( _today )
VAR _month = MONTH ( _today )
RETURN
CALCULATE ( COUNT ( Table1[column] ), 'Date Table'[Month] = _month, 'Date Table'[Year] = _year )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Nov 2023 16:50:51 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-current-month-amp-previous-month-values/m-p/3535537#M135859</guid>
      <dc:creator>ERD</dc:creator>
      <dc:date>2023-11-15T16:50:51Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate current month &amp; previous month values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-current-month-amp-previous-month-values/m-p/3544231#M136265</link>
      <description>&lt;P&gt;I get an error when using this calculation,&amp;nbsp;DAX comparison operations do not support comparing values of type Text with values of type Integer. Consider using the VALUE or FORMAT function to convert one of the values.&lt;/P&gt;&lt;P&gt;I do have a date table in my model, month is populated as Jul, Aug, Sep etc, and year is populated as 2021, 2022, 2023 etc. Any ideas where im going wrong?&lt;/P&gt;</description>
      <pubDate>Tue, 21 Nov 2023 09:15:02 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-current-month-amp-previous-month-values/m-p/3544231#M136265</guid>
      <dc:creator>blowers</dc:creator>
      <dc:date>2023-11-21T09:15:02Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate current month &amp; previous month values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-current-month-amp-previous-month-values/m-p/3544256#M136267</link>
      <description>&lt;P&gt;hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="634003" data-lia-user-login="blowers" class="lia-mention lia-mention-user"&gt;blowers&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;what does this mean: "&lt;SPAN&gt;use a day field (1-31) to display these in a graph for comparison.&lt;/SPAN&gt;"?&lt;/P&gt;</description>
      <pubDate>Tue, 21 Nov 2023 09:26:46 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-current-month-amp-previous-month-values/m-p/3544256#M136267</guid>
      <dc:creator>FreemanZ</dc:creator>
      <dc:date>2023-11-21T09:26:46Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate current month &amp; previous month values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-current-month-amp-previous-month-values/m-p/3544318#M136272</link>
      <description>&lt;P&gt;So the graph should have the days of the month, and then the current month and previous month counts over that monthly period. I keep having issues as it keeps counting the previous year in the graph calulations.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Nov 2023 09:51:25 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-current-month-amp-previous-month-values/m-p/3544318#M136272</guid>
      <dc:creator>blowers</dc:creator>
      <dc:date>2023-11-21T09:51:25Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate current month &amp; previous month values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-current-month-amp-previous-month-values/m-p/3546631#M136380</link>
      <description>&lt;P&gt;I was overthinking this&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt;. Used these calcs and then applied slicers for month &amp;amp; year on the graph&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Current Month Year = &lt;/SPAN&gt;&lt;SPAN&gt;CALCULATE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;SUM&lt;/SPAN&gt;&lt;SPAN&gt; (&lt;/SPAN&gt;&lt;SPAN&gt;table[count]&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&lt;SPAN&gt;Previous Month Year =&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;DIV&gt;&lt;SPAN&gt;CALCULATE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;SUM&lt;/SPAN&gt;&lt;SPAN&gt; (&lt;/SPAN&gt;&lt;SPAN&gt;table[count]&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;SAMEPERIODLASTYEAR&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'Date Table'[Date]&lt;/SPAN&gt;&lt;SPAN&gt;))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 22 Nov 2023 11:01:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-current-month-amp-previous-month-values/m-p/3546631#M136380</guid>
      <dc:creator>blowers</dc:creator>
      <dc:date>2023-11-22T11:01:26Z</dc:date>
    </item>
  </channel>
</rss>

