<?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: Custom Cycle within Date Calendar in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Custom-Cycle-within-Date-Calendar/m-p/3556561#M136922</link>
    <description>&lt;P&gt;could you depict your expected result with an table?&lt;/P&gt;</description>
    <pubDate>Tue, 28 Nov 2023 13:45:38 GMT</pubDate>
    <dc:creator>FreemanZ</dc:creator>
    <dc:date>2023-11-28T13:45:38Z</dc:date>
    <item>
      <title>Custom Cycle within Date Calendar</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Custom-Cycle-within-Date-Calendar/m-p/3556535#M136917</link>
      <description>&lt;P&gt;I am trying to add a custom Production Cycle Start Date to a date table. There is a production cycle lasting 14 days starting on a Thursday (the latest starting 23/11/2023) - i'd like to use this dimension for some reporting,&lt;BR /&gt;&lt;BR /&gt;The table is defined as:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Date = 

VAR _fromYear=YEAR(MIN('Members'[Date created])) // set the start year of the date dimension. dates start from 1st of January of this year
VAR _toYear=YEAR(MAX('Members'[Date created])) + 1   // set the end year of the date dimension. dates end at 31st of December of this year

//************** 
VAR _today=TODAY()
RETURN
ADDCOLUMNS(
    CALENDAR(
                DATE(_fromYear,1,1),
                DATE(_toYear,12,31)
),
"Year",YEAR([Date]),
"Start of Year",DATE( YEAR([Date]),1,1),
"End of Year",DATE( YEAR([Date]),12,31),
"Month",MONTH([Date]),
"Start of Month",DATE( YEAR([Date]), MONTH([Date]), 1),
"End of Month",EOMONTH([Date],0),
"Days in Month",DATEDIFF(DATE( YEAR([Date]), MONTH([Date]), 1),EOMONTH([Date],0),DAY)+1,
"Year Month Number",INT(FORMAT([Date],"YYYYMM")),
"Year Month Name",FORMAT([Date],"YYYY-MMM"),
"Day",DAY([Date]),
"Day Name",FORMAT([Date],"DDDD"),
"Day Name Short",FORMAT([Date],"DDD"),
"Day of Week",WEEKDAY([Date]),
"Day of Year",DATEDIFF(DATE( YEAR([Date]), 1, 1),[Date],DAY)+1,
"Month Name",FORMAT([Date],"MMMM"),
"Month Name Short",FORMAT([Date],"MMM"),
"Week of Year",WEEKNUM([Date],2),
"Start of Week", [Date]-WEEKDAY([Date],2)+1,
"End of Week",[Date]+7-WEEKDAY([Date], 2),
"Day Offset",DATEDIFF(_today,[Date],DAY),
"Month Offset",DATEDIFF(_today,[Date],MONTH),
"Year Offset",DATEDIFF(_today,[Date],YEAR)
)&lt;/LI-CODE&gt;&lt;P&gt;.&lt;BR /&gt;&lt;BR /&gt;I have had a few unsuccessful attempts at building this production cycle into the date table, the latest being the below, but this isn't repeating the values for each day within a cycle and looks to be just wrong.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Date = 

VAR _fromYear=YEAR(MIN('Members'[Date created])) // set the start year of the date dimension. dates start from 1st of January of this year
VAR _toYear=YEAR(MAX('Members'[Date created])) + 1   // set the end year of the date dimension. dates end at 31st of December of this year

VAR Prod_Base_Start_Date = 
    DATE(1900, 1, 1) -  
        INT( 
            DATEDIFF(
                DATE(2023, 11, 23),
                DATE(1900, 1, 1), 
                DAY
            ) / 14
        ) * 14
 

//************** 
VAR _today=TODAY()
VAR DateTable =
ADDCOLUMNS(
    CALENDAR(
                DATE(_fromYear,1,1),
                DATE(_toYear,12,31)
),
"Year",YEAR([Date]),
"Start of Year",DATE( YEAR([Date]),1,1),
"End of Year",DATE( YEAR([Date]),12,31),
"Month",MONTH([Date]),
"Start of Month",DATE( YEAR([Date]), MONTH([Date]), 1),
"End of Month",EOMONTH([Date],0),
"Days in Month",DATEDIFF(DATE( YEAR([Date]), MONTH([Date]), 1),EOMONTH([Date],0),DAY)+1,
"Year Month Number",INT(FORMAT([Date],"YYYYMM")),
"Year Month Name",FORMAT([Date],"YYYY-MMM"),
"Day",DAY([Date]),
"Day Name",FORMAT([Date],"DDDD"),
"Day Name Short",FORMAT([Date],"DDD"),
"Day of Week",WEEKDAY([Date]),
"Day of Year",DATEDIFF(DATE( YEAR([Date]), 1, 1),[Date],DAY)+1,
"Month Name",FORMAT([Date],"MMMM"),
"Month Name Short",FORMAT([Date],"MMM"),
"Week of Year",WEEKNUM([Date],2),
"Start of Week", [Date]-WEEKDAY([Date],2)+1,
"End of Week",[Date]+7-WEEKDAY([Date], 2),
"Day Offset",DATEDIFF(_today,[Date],DAY),
"Month Offset",DATEDIFF(_today,[Date],MONTH),
"Year Offset",DATEDIFF(_today,[Date],YEAR),
"Days_Since_Prod_Start", DATEDIFF([Date], Prod_Base_Start_Date, DAY)
)

RETURN
    ADDCOLUMNS(
        DateTable,
        "Prod_Cycle_Start_Date", IF( MOD([Days_Since_Prod_Start], 14) = 0, Prod_Base_Start_Date + [Days_Since_Prod_Start]))&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 28 Nov 2023 13:32:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Custom-Cycle-within-Date-Calendar/m-p/3556535#M136917</guid>
      <dc:creator>SACooper</dc:creator>
      <dc:date>2023-11-28T13:32:50Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Cycle within Date Calendar</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Custom-Cycle-within-Date-Calendar/m-p/3556561#M136922</link>
      <description>&lt;P&gt;could you depict your expected result with an table?&lt;/P&gt;</description>
      <pubDate>Tue, 28 Nov 2023 13:45:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Custom-Cycle-within-Date-Calendar/m-p/3556561#M136922</guid>
      <dc:creator>FreemanZ</dc:creator>
      <dc:date>2023-11-28T13:45:38Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Cycle within Date Calendar</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Custom-Cycle-within-Date-Calendar/m-p/3556599#M136929</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;here's Mock up of what I would be expecting the cucstom cycle in red.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Nov 2023 14:03:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Custom-Cycle-within-Date-Calendar/m-p/3556599#M136929</guid>
      <dc:creator>SACooper</dc:creator>
      <dc:date>2023-11-28T14:03:03Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Cycle within Date Calendar</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Custom-Cycle-within-Date-Calendar/m-p/3556725#M136943</link>
      <description>&lt;P&gt;hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="365285" data-lia-user-login="SACooper" class="lia-mention lia-mention-user"&gt;SACooper&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;not sure if i fully get you, try to create a calculated table like:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;dates = 
VAR _table = CALENDAR(DATE(2023,11,23), DATE(2024,1,1))
RETURN
ADDCOLUMNS(
    _table,
    "PeriodStart",
    VAR _gap =  MOD( DATEDIFF([date], DATE(2023,11,23), DAY), 14)
    VAR _startdate =
        MAXX(
            FILTER(
                _table,
                [date]&amp;lt;=EARLIER([date])
                    &amp;amp;&amp;amp; MOD( DATEDIFF([date], DATE(2023,11,23), DAY), 14) =0
            ),
            [date]
        )
    RETURN
    IF(
        _gap=0,
        [date],
        _startdate
    )
)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;it worked like:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Nov 2023 14:48:58 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Custom-Cycle-within-Date-Calendar/m-p/3556725#M136943</guid>
      <dc:creator>FreemanZ</dc:creator>
      <dc:date>2023-11-28T14:48:58Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Cycle within Date Calendar</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Custom-Cycle-within-Date-Calendar/m-p/3556945#M136965</link>
      <description>&lt;P&gt;Thank you this is excactly what I needed&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Nov 2023 16:54:53 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Custom-Cycle-within-Date-Calendar/m-p/3556945#M136965</guid>
      <dc:creator>SACooper</dc:creator>
      <dc:date>2023-11-28T16:54:53Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Cycle within Date Calendar</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Custom-Cycle-within-Date-Calendar/m-p/3557651#M136994</link>
      <description>&lt;P&gt;hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="365285" data-lia-user-login="SACooper" class="lia-mention lia-mention-user"&gt;SACooper&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;you may also try this:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;dates2 = 
VAR _table = CALENDAR(DATE(2023,11,23), DATE(2024,1,1))
RETURN
    ADDCOLUMNS(
        _table,
        "column",
        VAR _date = [date]
        RETURN
        MAXX(
            FILTER(
                _table, 
                AND(
                    [date]&amp;lt;=_date,
                    MOD( DATEDIFF([date], DATE(2023,11,23), DAY), 14)=0
                )
            ),
            [date]
        )
    )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Nov 2023 01:37:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Custom-Cycle-within-Date-Calendar/m-p/3557651#M136994</guid>
      <dc:creator>FreemanZ</dc:creator>
      <dc:date>2023-11-29T01:37:13Z</dc:date>
    </item>
  </channel>
</rss>

