<?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 doesn't contain one week in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-doesn-t-contain-one-week/m-p/3824100#M149545</link>
    <description>&lt;P&gt;Hi Liu Yang,&lt;/P&gt;&lt;P&gt;your measure works perfect, thank you so much, but there is one mistake, see the prinscreen and PBIX file (&lt;A href="https://drive.google.com/file/d/1TBLqi8cRoaFFkxVG50C_fjSnwNDaf-MW/view?usp=sharing" target="_blank"&gt;https://drive.google.com/file/d/1TBLqi8cRoaFFkxVG50C_fjSnwNDaf-MW/view?usp=sharing&lt;/A&gt;)&lt;/P&gt;&lt;P&gt;for weeks number 2 (2022-02, 2023-03 and 2024-02) it is showing incorrect values. Can you please fix this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&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>Tue, 09 Apr 2024 14:52:41 GMT</pubDate>
    <dc:creator>lucie_rabochova</dc:creator>
    <dc:date>2024-04-09T14:52:41Z</dc:date>
    <item>
      <title>Measure doesn't contain one week</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-doesn-t-contain-one-week/m-p/3817493#M149299</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have a measure calculating previous week sessions and I need to remove week 2022-53 and 2023-53 from this measure, because there is no sessions and it causing me blank space - see print screen.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;sessions - previous week = 
VAR CurrentWeek = SELECTEDVALUE(DimDates[Weeknumber])
VAR CurrentYear = SELECTEDVALUE(DimDates[Year])
VAR MaxWeekNumber = CALCULATE(MAX(DimDates[Weeknumber]),ALL(DimDates))

RETURN
SUMX(
    FILTER( ALL(DimDates),
        IF(CurrentWeek = 1,
            DimDates[Weeknumber] = MaxWeekNumber &amp;amp;&amp;amp; DimDates[Year] = CurrentYear - 1,
            DimDates[Weeknumber] = CurrentWeek - 1 &amp;amp;&amp;amp; DimDates[Year] = CurrentYear ) ),
    [LegoSessions(Channel)]
    )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My goal is:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;remove weeks 2022-52 and 2023-53&lt;/LI&gt;&lt;LI&gt;week 2022-52 will be previous week of 2023-01&lt;/LI&gt;&lt;LI&gt;week 2023-52 will be previous week of 2024-01&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Thank you for your help.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Apr 2024 04:11:59 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-doesn-t-contain-one-week/m-p/3817493#M149299</guid>
      <dc:creator>lucie_rabochova</dc:creator>
      <dc:date>2024-04-08T04:11:59Z</dc:date>
    </item>
    <item>
      <title>Re: Measure doesn't contain one week</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-doesn-t-contain-one-week/m-p/3817955#M149320</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Here's the modified version of your measure:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;sessions - previous week =&lt;BR /&gt;VAR CurrentWeek = SELECTEDVALUE(DimDates[Weeknumber])&lt;BR /&gt;VAR CurrentYear = SELECTEDVALUE(DimDates[Year])&lt;BR /&gt;VAR MaxWeekNumber = CALCULATE(MAX(DimDates[Weeknumber]), ALL(DimDates))&lt;/P&gt;&lt;P&gt;RETURN&lt;BR /&gt;SUMX(&lt;BR /&gt;FILTER(&lt;BR /&gt;ALL(DimDates),&lt;BR /&gt;IF(&lt;BR /&gt;CurrentWeek = 1,&lt;BR /&gt;IF(&lt;BR /&gt;DimDates[Weeknumber] = MaxWeekNumber &amp;amp;&amp;amp; DimDates[Year] = CurrentYear - 1,&lt;BR /&gt;TRUE(),&lt;BR /&gt;FALSE()&lt;BR /&gt;),&lt;BR /&gt;IF(&lt;BR /&gt;CurrentWeek = 2 &amp;amp;&amp;amp; MaxWeekNumber = 52,&lt;BR /&gt;DimDates[Weeknumber] = 1 &amp;amp;&amp;amp; DimDates[Year] = CurrentYear,&lt;BR /&gt;IF(&lt;BR /&gt;CurrentWeek = 2 &amp;amp;&amp;amp; MaxWeekNumber = 53,&lt;BR /&gt;DimDates[Weeknumber] = 1 &amp;amp;&amp;amp; DimDates[Year] = CurrentYear + 1,&lt;BR /&gt;DimDates[Weeknumber] = CurrentWeek - 1 &amp;amp;&amp;amp; DimDates[Year] = CurrentYear&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;),&lt;BR /&gt;[LegoSessions(Channel)]&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In this modified version:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;If the current week is the first week of the year and the maximum week number is 52, it considers the previous week as week 1 of the current year.&lt;/LI&gt;&lt;LI&gt;If the current week is the first week of the year and the maximum week number is 53, it considers the previous week as week 1 of the next year.&lt;/LI&gt;&lt;LI&gt;For all other cases, it calculates the previous week normally.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;This adjustment should remove the blank spaces caused by weeks 2022-52 and 2023-53 and correctly calculate the previous week sessions as per your requirements&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;If this post&amp;nbsp;helps, then please consider&amp;nbsp;Accepting it as the solution&amp;nbsp;to help the other members find it more quickly.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;In case there is still a problem, please feel free and explain your issue in detail,&amp;nbsp;It will be my pleasure to assist you in any way I can.&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Apr 2024 06:36:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-doesn-t-contain-one-week/m-p/3817955#M149320</guid>
      <dc:creator>123abc</dc:creator>
      <dc:date>2024-04-08T06:36:42Z</dc:date>
    </item>
    <item>
      <title>Re: Measure doesn't contain one week</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-doesn-t-contain-one-week/m-p/3821507#M149452</link>
      <description>&lt;P&gt;Hi 123abc,&lt;/P&gt;&lt;P&gt;Thank you for your help, but updated measure doesn't work as I expected. I'm attaching PBIX file :&lt;/P&gt;&lt;P&gt;&lt;A href="https://drive.google.com/file/d/1TBLqi8cRoaFFkxVG50C_fjSnwNDaf-MW/view?usp=sharing" target="_blank" rel="nofollow noopener noreferrer"&gt;https://drive.google.com/file/d/1TBLqi8cRoaFFkxVG50C_fjSnwNDaf-MW/view?usp=sharing&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Previous week for 2023-01 should be 2022-52 but it's still blank and 53 weeks still showing...&lt;/P&gt;&lt;P&gt;Can you please have a look at the file?&lt;/P&gt;</description>
      <pubDate>Tue, 09 Apr 2024 04:44:53 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-doesn-t-contain-one-week/m-p/3821507#M149452</guid>
      <dc:creator>lucie_rabochova</dc:creator>
      <dc:date>2024-04-09T04:44:53Z</dc:date>
    </item>
    <item>
      <title>Re: Measure doesn't contain one week</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-doesn-t-contain-one-week/m-p/3821763#M149465</link>
      <description>&lt;P&gt;Hi&amp;nbsp; &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="617908" data-lia-user-login="lucie_rabochova" class="lia-mention lia-mention-user"&gt;lucie_rabochova&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can try using the following dax.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Dax_sessions - previous week =
VAR CurrentWeek =
    SELECTEDVALUE ( DimDates[Weeknumber] )
VAR CurrentYear =
    SELECTEDVALUE ( DimDates[Year] )
VAR MaxWeekNumber =
    CALCULATE ( MAX ( DimDates[Weeknumber] ), ALL ( DimDates ) )
RETURN
    SWITCH (
        TRUE (),
        MAX ( 'DimDates'[Weeknumber] ) = 1,
            SUMX (
                FILTER (
                    ALL ( 'DimDates' ),
                    'DimDates'[Year]
                        = MAX ( 'DimDates'[Year] ) - 1
                        &amp;amp;&amp;amp; 'DimDates'[Weeknumber]
                            = MAXX (
                                FILTER ( ALL ( 'DimDates' ), 'DimDates'[Year] = MAX ( 'DimDates'[Year] ) - 1 ),
                                [Weeknumber]
                            ) - 1
                ),
                [LegoSessions(Channel)]
            ),
        CurrentWeek = 2
            &amp;amp;&amp;amp; MaxWeekNumber = 52,
            SUMX (
                FILTER (
                    ALL ( 'DimDates' ),
                    DimDates[Weeknumber] = 1
                        &amp;amp;&amp;amp; DimDates[Year] = CurrentYear
                ),
                [LegoSessions(Channel)]
            ),
        CurrentWeek = 2
            &amp;amp;&amp;amp; MaxWeekNumber = 53,
            SUMX (
                FILTER (
                    ALL ( 'DimDates' ),
                    DimDates[Weeknumber] = 1
                        &amp;amp;&amp;amp; DimDates[Year] = CurrentYear + 1
                ),
                [LegoSessions(Channel)]
            ),
        MAX ( 'DimDates'[Weeknumber] )
            = MAXX (
                FILTER ( ALL ( 'DimDates' ), 'DimDates'[Year] = MAX ( 'DimDates'[Year] ) ),
                [Weeknumber]
            ), BLANK (),
        SUMX (
            FILTER (
                ALL ( 'DimDates' ),
                DimDates[Weeknumber] = CurrentWeek - 1
                    &amp;amp;&amp;amp; DimDates[Year] = CurrentYear
            ),
            [LegoSessions(Channel)]
        )
    )
&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Liu Yang&lt;/P&gt;
&lt;P&gt;If this post &lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider &lt;EM&gt;Accept it as the solution&lt;/EM&gt; to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Apr 2024 06:14:06 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-doesn-t-contain-one-week/m-p/3821763#M149465</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-04-09T06:14:06Z</dc:date>
    </item>
    <item>
      <title>Re: Measure doesn't contain one week</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-doesn-t-contain-one-week/m-p/3824100#M149545</link>
      <description>&lt;P&gt;Hi Liu Yang,&lt;/P&gt;&lt;P&gt;your measure works perfect, thank you so much, but there is one mistake, see the prinscreen and PBIX file (&lt;A href="https://drive.google.com/file/d/1TBLqi8cRoaFFkxVG50C_fjSnwNDaf-MW/view?usp=sharing" target="_blank"&gt;https://drive.google.com/file/d/1TBLqi8cRoaFFkxVG50C_fjSnwNDaf-MW/view?usp=sharing&lt;/A&gt;)&lt;/P&gt;&lt;P&gt;for weeks number 2 (2022-02, 2023-03 and 2024-02) it is showing incorrect values. Can you please fix this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&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>Tue, 09 Apr 2024 14:52:41 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-doesn-t-contain-one-week/m-p/3824100#M149545</guid>
      <dc:creator>lucie_rabochova</dc:creator>
      <dc:date>2024-04-09T14:52:41Z</dc:date>
    </item>
    <item>
      <title>Re: Measure doesn't contain one week</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-doesn-t-contain-one-week/m-p/3832512#M149862</link>
      <description>&lt;P&gt;Any update here please?&lt;/P&gt;</description>
      <pubDate>Fri, 12 Apr 2024 04:52:46 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-doesn-t-contain-one-week/m-p/3832512#M149862</guid>
      <dc:creator>lucie_rabochova</dc:creator>
      <dc:date>2024-04-12T04:52:46Z</dc:date>
    </item>
    <item>
      <title>Re: Measure doesn't contain one week</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-doesn-t-contain-one-week/m-p/3832851#M149880</link>
      <description>&lt;P&gt;Hi&amp;nbsp; &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="617908" data-lia-user-login="lucie_rabochova" class="lia-mention lia-mention-user"&gt;lucie_rabochova&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If week 2 wants to display the values from week 1, you can use the following dax:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Dax_sessions - previous week =
VAR CurrentWeek = SELECTEDVALUE(DimDates[Weeknumber])
VAR CurrentYear = SELECTEDVALUE(DimDates[Year])
VAR MaxWeekNumber = CALCULATE(MAX(DimDates[Weeknumber]), ALL(DimDates))
RETURN
SWITCH(
    TRUE(),
    MAX('DimDates'[Weeknumber])=1,
SUMX(FILTER(ALL('DimDates'),'DimDates'[Year]=MAX('DimDates'[Year])-1
&amp;amp;&amp;amp;'DimDates'[Weeknumber]=MAXX(FILTER(ALL('DimDates'),'DimDates'[Year]=MAX('DimDates'[Year])-1),[Weeknumber])-1),[LegoSessions(Channel)]),
MAX('DimDates'[Weeknumber])=MAXX(FILTER(ALL('DimDates'),'DimDates'[Year]=MAX('DimDates'[Year])),[Weeknumber]),BLANK(),
SUMX(FILTER(ALL('DimDates'),
DimDates[Weeknumber] = CurrentWeek - 1 &amp;amp;&amp;amp; DimDates[Year] = CurrentYear),[LegoSessions(Channel)]))&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Liu Yang&lt;/P&gt;
&lt;P&gt;If this post &lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider &lt;EM&gt;Accept it as the solution&lt;/EM&gt; to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Apr 2024 07:18:16 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-doesn-t-contain-one-week/m-p/3832851#M149880</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-04-12T07:18:16Z</dc:date>
    </item>
  </channel>
</rss>

