<?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: How to determine the &amp;quot;same&amp;quot; date in the month last year based on working days remaining in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-determine-the-quot-same-quot-date-in-the-month-last-year/m-p/3601792#M139170</link>
    <description>&lt;P&gt;Hi, &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="664657" data-lia-user-login="Jan_Cools" class="lia-mention lia-mention-user"&gt;Jan_Cools&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;May I ask if this is the expected output you are looking for? Based on your description, I have created many measures to achieve the effect you are looking for. Following picture shows the effect of the display.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Measures:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Remaining_Work_Days =

VAR remaining_Work_Days =

    NETWORKDAYS ( SELECTEDVALUE ( 'Table'[Date] ), ENDOFMONTH ( 'Table'[Date] ), 1 )

RETURN

    remaining_Work_Days



SameWorkingDayLastYear =

VAR SelectedDate =

    SELECTEDVALUE ( 'Table'[Date] )

VAR SameDayLastYear =

    SAMEPERIODLASTYEAR ( 'Table'[Date] )

VAR SameMonthLastYear =

    EOMONTH ( SelectedDate, -12 )

VAR WorkingDaysLastYear =

    NETWORKDAYS ( SameDayLastYear, SameMonthLastYear )

RETURN

    WorkingDaysLastYear



TrueValuesLastYear =

VAR DIFFDAYS = [Remaining_Work_Days] - [SameWorkingDayLastYear]

VAR SelectedDate =

    SELECTEDVALUE ( 'Table'[Date] )

VAR SameDayLastYear =

    SAMEPERIODLASTYEAR ( 'Table'[Date] )

VAR StartMonthLastYear =

    EOMONTH ( SelectedDate, -13 ) + 1

VAR _tureSameDayLastYear =

    SWITCH (

        DIFFDAYS,

        -1,

            SWITCH (

                TRUE (),

                WEEKDAY ( SameDayLastYear + 1 ) = 7, SameDayLastYear + 3,

                WEEKDAY ( SameDayLastYear + 1 ) = 1, SameDayLastYear + 2,

                SameDayLastYear + 1

            ),

        -2,

            SWITCH (

                TRUE (),

                WEEKDAY ( SameDayLastYear + 2 ) = 7, SameDayLastYear + 4,

                WEEKDAY ( SameDayLastYear + 2 ) = 1, SameDayLastYear + 3,

                SameDayLastYear + 2

            ),

        -3,

            SWITCH (

                TRUE (),

                WEEKDAY ( SameDayLastYear + 3 ) = 7, SameDayLastYear + 5,

                WEEKDAY ( SameDayLastYear + 3 ) = 1, SameDayLastYear + 4,

                SameDayLastYear + 3

            ),

        1,

            SWITCH (

                TRUE (),

                WEEKDAY ( SameDayLastYear - 1 ) = 7, SameDayLastYear - 2,

                WEEKDAY ( SameDayLastYear - 1 ) = 1, SameDayLastYear - 3,

                SameDayLastYear - 1

            ),

        2,

            SWITCH (

                TRUE (),

                WEEKDAY ( SameDayLastYear - 2 ) = 7, SameDayLastYear - 4,

                WEEKDAY ( SameDayLastYear - 2 ) = 1, SameDayLastYear - 3,

                SameDayLastYear - 2

            ),

        3,

            SWITCH (

                TRUE (),

                WEEKDAY ( SameDayLastYear - 3 ) = 7, SameDayLastYear - 5,

                WEEKDAY ( SameDayLastYear - 3 ) = 1, SameDayLastYear - 4,

                SameDayLastYear - 3

            ),

        SameDayLastYear

    )

VAR _ValuesLastYear =

    CALCULATE (

        SUM ( 'CALENDAR'[Value] ),

        'CALENDAR'[Date] &amp;gt;= StartMonthLastYear

            &amp;amp;&amp;amp; 'CALENDAR'[Date] &amp;lt;= _tureSameDayLastYear

    )

RETURN

    _ValuesLastYear



ValuesThisYear =

VAR SelectedDate =

    SELECTEDVALUE ( 'Table'[Date] )

VAR DateStartOfMonth =

    EOMONTH ( SelectedDate, -1 ) + 1

VAR _ValuesThisYear =

    CALCULATE (

        SUM ( 'CALENDAR'[Value] ),

        'CALENDAR'[Date] &amp;gt;= DateStartOfMonth

            &amp;amp;&amp;amp; 'CALENDAR'[Date] &amp;lt;= SelectedDate

    )

RETURN

    _ValuesThisYear&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this does not work, could you please share some sample data without sensitive information and expected output.&lt;BR /&gt;&lt;A href="https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216" target="_blank" rel="noopener"&gt;How to provide sample data in the Power BI Forum - Microsoft Fabric Community&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Best Regards,&lt;BR /&gt;Yang&lt;BR /&gt;Community Support Team&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If there is any post&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;helps&lt;/EM&gt;&lt;/STRONG&gt;, then please consider&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Accept it as the solution&lt;/EM&gt;&lt;/STRONG&gt;&amp;nbsp;&amp;nbsp;to help the other members find it more quickly.&lt;BR /&gt;If I misunderstand your needs or you still have problems on it, please feel free to let us know.&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Thanks a lot!&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490" target="_blank" rel="noopener"&gt;How to get your questions answered quickly&lt;/A&gt;&amp;nbsp;--&amp;nbsp;&lt;A href="https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216" target="_blank" rel="noopener"&gt;&amp;nbsp;How to provide sample data in the Power BI Forum&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 26 Dec 2023 08:01:45 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2023-12-26T08:01:45Z</dc:date>
    <item>
      <title>How to determine the "same" date in the month last year based on working days remaining</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-determine-the-quot-same-quot-date-in-the-month-last-year/m-p/3598640#M139046</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;first post in this forum!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm struggling to get a workaround the following issue:&lt;/P&gt;&lt;P&gt;I've created some visuals where I can follow the day to day cumulative (month to date) sales for a specific month.&lt;/P&gt;&lt;P&gt;Based on a slicer, I select a certain date in the month and would like to compare the month to date sales value with the same month last year, but the related date, last year, should be the one that has the same amount of working days left as the date I selected in the filter.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I used the function NETWORKINGDAYS to determine how many working days are left in the month for which I picked the date, but how to get the relevant date in the month of previous year.&lt;/P&gt;&lt;P&gt;For the ease of understanding, assume that only Saturday and Sundays are non working days.&lt;/P&gt;&lt;P&gt;Any help is welcome!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The formula used to determine the working days left based on selection is:&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Remaining_Work_Days =&lt;/SPAN&gt; &lt;SPAN&gt;NETWORKDAYS&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;SELECTEDVALUE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'CALENDAR'&lt;/SPAN&gt;&lt;SPAN&gt;[Date]&lt;/SPAN&gt;&lt;SPAN&gt;),&lt;/SPAN&gt;&lt;SPAN&gt;ENDOFMONTH&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'CALENDAR'&lt;/SPAN&gt;&lt;SPAN&gt;[Date]&lt;/SPAN&gt;&lt;SPAN&gt;),&lt;/SPAN&gt;&lt;SPAN&gt;1&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;Calendar table is in place and all relevant relationships, with the sales table, are made.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks, Jan&lt;/P&gt;</description>
      <pubDate>Fri, 22 Dec 2023 10:43:19 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-determine-the-quot-same-quot-date-in-the-month-last-year/m-p/3598640#M139046</guid>
      <dc:creator>Jan_Cools</dc:creator>
      <dc:date>2023-12-22T10:43:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to determine the "same" date in the month last year based on working days remaining</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-determine-the-quot-same-quot-date-in-the-month-last-year/m-p/3598968#M139066</link>
      <description>&lt;P&gt;If you can share sample file it will be great&lt;/P&gt;</description>
      <pubDate>Fri, 22 Dec 2023 15:50:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-determine-the-quot-same-quot-date-in-the-month-last-year/m-p/3598968#M139066</guid>
      <dc:creator>saudansari</dc:creator>
      <dc:date>2023-12-22T15:50:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to determine the "same" date in the month last year based on working days remaining</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-determine-the-quot-same-quot-date-in-the-month-last-year/m-p/3601792#M139170</link>
      <description>&lt;P&gt;Hi, &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="664657" data-lia-user-login="Jan_Cools" class="lia-mention lia-mention-user"&gt;Jan_Cools&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;May I ask if this is the expected output you are looking for? Based on your description, I have created many measures to achieve the effect you are looking for. Following picture shows the effect of the display.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Measures:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Remaining_Work_Days =

VAR remaining_Work_Days =

    NETWORKDAYS ( SELECTEDVALUE ( 'Table'[Date] ), ENDOFMONTH ( 'Table'[Date] ), 1 )

RETURN

    remaining_Work_Days



SameWorkingDayLastYear =

VAR SelectedDate =

    SELECTEDVALUE ( 'Table'[Date] )

VAR SameDayLastYear =

    SAMEPERIODLASTYEAR ( 'Table'[Date] )

VAR SameMonthLastYear =

    EOMONTH ( SelectedDate, -12 )

VAR WorkingDaysLastYear =

    NETWORKDAYS ( SameDayLastYear, SameMonthLastYear )

RETURN

    WorkingDaysLastYear



TrueValuesLastYear =

VAR DIFFDAYS = [Remaining_Work_Days] - [SameWorkingDayLastYear]

VAR SelectedDate =

    SELECTEDVALUE ( 'Table'[Date] )

VAR SameDayLastYear =

    SAMEPERIODLASTYEAR ( 'Table'[Date] )

VAR StartMonthLastYear =

    EOMONTH ( SelectedDate, -13 ) + 1

VAR _tureSameDayLastYear =

    SWITCH (

        DIFFDAYS,

        -1,

            SWITCH (

                TRUE (),

                WEEKDAY ( SameDayLastYear + 1 ) = 7, SameDayLastYear + 3,

                WEEKDAY ( SameDayLastYear + 1 ) = 1, SameDayLastYear + 2,

                SameDayLastYear + 1

            ),

        -2,

            SWITCH (

                TRUE (),

                WEEKDAY ( SameDayLastYear + 2 ) = 7, SameDayLastYear + 4,

                WEEKDAY ( SameDayLastYear + 2 ) = 1, SameDayLastYear + 3,

                SameDayLastYear + 2

            ),

        -3,

            SWITCH (

                TRUE (),

                WEEKDAY ( SameDayLastYear + 3 ) = 7, SameDayLastYear + 5,

                WEEKDAY ( SameDayLastYear + 3 ) = 1, SameDayLastYear + 4,

                SameDayLastYear + 3

            ),

        1,

            SWITCH (

                TRUE (),

                WEEKDAY ( SameDayLastYear - 1 ) = 7, SameDayLastYear - 2,

                WEEKDAY ( SameDayLastYear - 1 ) = 1, SameDayLastYear - 3,

                SameDayLastYear - 1

            ),

        2,

            SWITCH (

                TRUE (),

                WEEKDAY ( SameDayLastYear - 2 ) = 7, SameDayLastYear - 4,

                WEEKDAY ( SameDayLastYear - 2 ) = 1, SameDayLastYear - 3,

                SameDayLastYear - 2

            ),

        3,

            SWITCH (

                TRUE (),

                WEEKDAY ( SameDayLastYear - 3 ) = 7, SameDayLastYear - 5,

                WEEKDAY ( SameDayLastYear - 3 ) = 1, SameDayLastYear - 4,

                SameDayLastYear - 3

            ),

        SameDayLastYear

    )

VAR _ValuesLastYear =

    CALCULATE (

        SUM ( 'CALENDAR'[Value] ),

        'CALENDAR'[Date] &amp;gt;= StartMonthLastYear

            &amp;amp;&amp;amp; 'CALENDAR'[Date] &amp;lt;= _tureSameDayLastYear

    )

RETURN

    _ValuesLastYear



ValuesThisYear =

VAR SelectedDate =

    SELECTEDVALUE ( 'Table'[Date] )

VAR DateStartOfMonth =

    EOMONTH ( SelectedDate, -1 ) + 1

VAR _ValuesThisYear =

    CALCULATE (

        SUM ( 'CALENDAR'[Value] ),

        'CALENDAR'[Date] &amp;gt;= DateStartOfMonth

            &amp;amp;&amp;amp; 'CALENDAR'[Date] &amp;lt;= SelectedDate

    )

RETURN

    _ValuesThisYear&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this does not work, could you please share some sample data without sensitive information and expected output.&lt;BR /&gt;&lt;A href="https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216" target="_blank" rel="noopener"&gt;How to provide sample data in the Power BI Forum - Microsoft Fabric Community&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Best Regards,&lt;BR /&gt;Yang&lt;BR /&gt;Community Support Team&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If there is any post&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;helps&lt;/EM&gt;&lt;/STRONG&gt;, then please consider&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Accept it as the solution&lt;/EM&gt;&lt;/STRONG&gt;&amp;nbsp;&amp;nbsp;to help the other members find it more quickly.&lt;BR /&gt;If I misunderstand your needs or you still have problems on it, please feel free to let us know.&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Thanks a lot!&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490" target="_blank" rel="noopener"&gt;How to get your questions answered quickly&lt;/A&gt;&amp;nbsp;--&amp;nbsp;&lt;A href="https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216" target="_blank" rel="noopener"&gt;&amp;nbsp;How to provide sample data in the Power BI Forum&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Dec 2023 08:01:45 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-determine-the-quot-same-quot-date-in-the-month-last-year/m-p/3601792#M139170</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-12-26T08:01:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to determine the "same" date in the month last year based on working days remaining</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-determine-the-quot-same-quot-date-in-the-month-last-year/m-p/3601828#M139174</link>
      <description>&lt;P&gt;Perfect Anonymous&lt;/a&gt;&amp;nbsp;Yang!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;seems to be working as expected.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a lot.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Dec 2023 08:25:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-determine-the-quot-same-quot-date-in-the-month-last-year/m-p/3601828#M139174</guid>
      <dc:creator>Jan_Cools</dc:creator>
      <dc:date>2023-12-26T08:25:38Z</dc:date>
    </item>
  </channel>
</rss>

