<?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: Measure to count the distinct number of months in a date table in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-to-count-the-distinct-number-of-months-in-a-date-table/m-p/3261851#M120671</link>
    <description>&lt;P&gt;Thank you, Pat, that worked very well.&lt;/P&gt;&lt;P&gt;Many thanks for your help!&lt;/P&gt;</description>
    <pubDate>Wed, 31 May 2023 12:30:48 GMT</pubDate>
    <dc:creator>Chris2016</dc:creator>
    <dc:date>2023-05-31T12:30:48Z</dc:date>
    <item>
      <title>Measure to count the distinct number of months in a date table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-to-count-the-distinct-number-of-months-in-a-date-table/m-p/3261756#M120662</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could someone help with a measure to count the distinct number of months&amp;nbsp;in a date column (not coming from a Date table)? I need this to calculate an average per month. I know that I could just create a calculated column of Y&amp;amp;Mo from Date&lt;SPAN&gt;, but the report is already heavy and don't want to burden it unnecessarily.&lt;BR /&gt;&lt;BR /&gt;I already tried using DATEDIFF, but I don't think that will work properly if I start missing months in the Date column going forward (e.g. the current month of May is almost over, and I still do not have any data for this month - I expect it to be blank starting June 1st, and the calculation will be off when I start getting data in June).&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;&lt;SPAN&gt;NoofMo&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;CALCULATE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&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table'&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;NOT&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;ISBLANK&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;[Date]&lt;/SPAN&gt;&lt;SPAN&gt;))))&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;P&gt;&lt;SPAN&gt;Though this calculation works for now, I just need an actual distinct count of months in the Date column.&lt;BR /&gt;Many thanks for any idea!&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2023 11:50:02 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-to-count-the-distinct-number-of-months-in-a-date-table/m-p/3261756#M120662</guid>
      <dc:creator>Chris2016</dc:creator>
      <dc:date>2023-05-31T11:50:02Z</dc:date>
    </item>
    <item>
      <title>Re: Measure to count the distinct number of months in a date table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-to-count-the-distinct-number-of-months-in-a-date-table/m-p/3261813#M120668</link>
      <description>&lt;P&gt;Here's a measure expression that shows one way to do it. Although, I would consider adding a proper date table or yearmonth column and optimize your model in other areas.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;MonthsInColumn =
VAR dateswithmonth =
    ADDCOLUMNS (
        DISTINCT ( Sales[SaleDate] ),
        "cMon", EOMONTH ( Sales[SaleDate], 0 )
    )
RETURN
    COUNTROWS ( SUMMARIZE ( dateswithmonth, [cMon] ) )&lt;/LI-CODE&gt;&lt;P&gt;Pat&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2023 12:12:20 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-to-count-the-distinct-number-of-months-in-a-date-table/m-p/3261813#M120668</guid>
      <dc:creator>ppm1</dc:creator>
      <dc:date>2023-05-31T12:12:20Z</dc:date>
    </item>
    <item>
      <title>Re: Measure to count the distinct number of months in a date table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-to-count-the-distinct-number-of-months-in-a-date-table/m-p/3261851#M120671</link>
      <description>&lt;P&gt;Thank you, Pat, that worked very well.&lt;/P&gt;&lt;P&gt;Many thanks for your help!&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2023 12:30:48 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-to-count-the-distinct-number-of-months-in-a-date-table/m-p/3261851#M120671</guid>
      <dc:creator>Chris2016</dc:creator>
      <dc:date>2023-05-31T12:30:48Z</dc:date>
    </item>
  </channel>
</rss>

