<?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 Date Table with end of month variable in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Date-Table-with-end-of-month-variable/m-p/1544376#M30483</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In my organization, the end of the month can change based on the last day of the month.&lt;/P&gt;&lt;P&gt;If the last day of the month is between Thursday and Friday, the month ends the next Saturday.&lt;/P&gt;&lt;P&gt;If the last day is between Sunday and Wednesday, the month ends on Saturday before.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ex: November 2020 - Last day of the month is Monday, so the month ends the Saturday before (28th November). This means 29 and 30th November are part of December.&lt;/P&gt;&lt;P&gt;For December 2020:&amp;nbsp;Last day of the month is Thursday, so the month ends the Saturday after (2nd January). This means 1st and 2nd January are part of December, and so on.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm using a simple date table, however, I don't if it is possible to integrate the month logic of my organization inside it.&lt;/P&gt;&lt;P&gt;Any help will be amazing, even if it is to say that is better to create a date table by hand.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Dates = 
Var BaseCalendar = 
    CALENDAR("1/1/2017", "31/12/2021")
RETURN
    GENERATE(
        BaseCalendar,
        Var BaseDate = [Date]
        Var YearDate = YEAR(BaseDate)
        Var MonthNumber = MONTH(BaseDate)
        Var WeekDay =  [Date]
        Var WeekNumber = WEEKNUM(BaseDate,21)
        //Var FiscalQuarter = QUARTER(5) //Regler Fiscal Year si différent de 1
        Var CalendarQuarter = QUARTER(BaseDate)
        Var SameDateLY = DATE(YEAR(BaseDate)-1,MONTH(BaseDate), DAY(BaseDate))
        Var SameDateBLY = DATE(YEAR(BaseDate)-2,MONTH(BaseDate), DAY(BaseDate))

        RETURN ROW(
            "Day", BaseDate,
            "Year", YearDate,
            "Month Number", MonthNumber,
            "Month", FORMAT(BaseDate, "mmmm"),
            "Year Month", FORMAT(BaseDate, "mmm yy"),
            "Day Week", FORMAT(WeekDay, "dddd"),
            "Week Number", WeekNumber,
            //"Fiscal Quarter", FiscalQuarter,
            "Calendar Quarter", CalendarQuarter,
            "Same Date Last Year", SameDateLY,
            "Same Date Before Last Year", SameDateBLY
            )
    )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 11 Dec 2020 03:29:42 GMT</pubDate>
    <dc:creator>rodrigooliveira</dc:creator>
    <dc:date>2020-12-11T03:29:42Z</dc:date>
    <item>
      <title>Date Table with end of month variable</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Date-Table-with-end-of-month-variable/m-p/1544376#M30483</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In my organization, the end of the month can change based on the last day of the month.&lt;/P&gt;&lt;P&gt;If the last day of the month is between Thursday and Friday, the month ends the next Saturday.&lt;/P&gt;&lt;P&gt;If the last day is between Sunday and Wednesday, the month ends on Saturday before.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ex: November 2020 - Last day of the month is Monday, so the month ends the Saturday before (28th November). This means 29 and 30th November are part of December.&lt;/P&gt;&lt;P&gt;For December 2020:&amp;nbsp;Last day of the month is Thursday, so the month ends the Saturday after (2nd January). This means 1st and 2nd January are part of December, and so on.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm using a simple date table, however, I don't if it is possible to integrate the month logic of my organization inside it.&lt;/P&gt;&lt;P&gt;Any help will be amazing, even if it is to say that is better to create a date table by hand.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Dates = 
Var BaseCalendar = 
    CALENDAR("1/1/2017", "31/12/2021")
RETURN
    GENERATE(
        BaseCalendar,
        Var BaseDate = [Date]
        Var YearDate = YEAR(BaseDate)
        Var MonthNumber = MONTH(BaseDate)
        Var WeekDay =  [Date]
        Var WeekNumber = WEEKNUM(BaseDate,21)
        //Var FiscalQuarter = QUARTER(5) //Regler Fiscal Year si différent de 1
        Var CalendarQuarter = QUARTER(BaseDate)
        Var SameDateLY = DATE(YEAR(BaseDate)-1,MONTH(BaseDate), DAY(BaseDate))
        Var SameDateBLY = DATE(YEAR(BaseDate)-2,MONTH(BaseDate), DAY(BaseDate))

        RETURN ROW(
            "Day", BaseDate,
            "Year", YearDate,
            "Month Number", MonthNumber,
            "Month", FORMAT(BaseDate, "mmmm"),
            "Year Month", FORMAT(BaseDate, "mmm yy"),
            "Day Week", FORMAT(WeekDay, "dddd"),
            "Week Number", WeekNumber,
            //"Fiscal Quarter", FiscalQuarter,
            "Calendar Quarter", CalendarQuarter,
            "Same Date Last Year", SameDateLY,
            "Same Date Before Last Year", SameDateBLY
            )
    )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Dec 2020 03:29:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Date-Table-with-end-of-month-variable/m-p/1544376#M30483</guid>
      <dc:creator>rodrigooliveira</dc:creator>
      <dc:date>2020-12-11T03:29:42Z</dc:date>
    </item>
    <item>
      <title>Re: Date Table with end of month variable</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Date-Table-with-end-of-month-variable/m-p/1546190#M30536</link>
      <description>&lt;P&gt;Bonjour,&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="213425" data-lia-user-login="rodrigooliveira" class="lia-mention lia-mention-user"&gt;rodrigooliveira&lt;/a&gt;&amp;nbsp;, c'est un véritable casse-tête, n'est-ce pas? Essaie la formule dans une colonne calculée,&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Month Adapted = 
VAR __weeknum = WEEKNUM ( [Date] )
VAR __day = DAY ( [Date] )
VAR __month_natural = MONTH ( [Date] )
VAR __eom = IF ( __day &amp;lt; 7, EOMONTH ( [Date], -1 ), EOMONTH ( [Date], 0 ) )
RETURN
    IF (//the very last week of a month
        __weeknum = WEEKNUM ( EOMONTH ( [Date], 0 ) ) //within the last week of a month
            || __weeknum = MOD ( WEEKNUM ( [Date] - __day ), 52 ), //weeknum of previous end of month
        IF (
            WEEKDAY ( __eom ) &amp;gt;= 5,
            MONTH ( __eom ),
            MONTH ( __eom + 1 )
        ),
        __month_natural
    )&lt;/LI-CODE&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Dec 2020 19:44:10 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Date-Table-with-end-of-month-variable/m-p/1546190#M30536</guid>
      <dc:creator>CNENFRNL</dc:creator>
      <dc:date>2020-12-11T19:44:10Z</dc:date>
    </item>
    <item>
      <title>Re: Date Table with end of month variable</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Date-Table-with-end-of-month-variable/m-p/1546380#M30541</link>
      <description>&lt;P&gt;Merci beaucoup! Thank you!&lt;/P&gt;</description>
      <pubDate>Sat, 12 Dec 2020 00:23:10 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Date-Table-with-end-of-month-variable/m-p/1546380#M30541</guid>
      <dc:creator>rodrigooliveira</dc:creator>
      <dc:date>2020-12-12T00:23:10Z</dc:date>
    </item>
  </channel>
</rss>

