<?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: Sales YTD based on Week Selection in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sales-YTD-based-on-Week-Selection/m-p/2744262#M84482</link>
    <description>&lt;P&gt;Well, just start working on it and you'll see the point immediately &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; Just remember that when a measure returns a BLANK for a dimension attribute's value, the attribute gets hidden from the user's view.&lt;/P&gt;</description>
    <pubDate>Fri, 02 Sep 2022 18:44:16 GMT</pubDate>
    <dc:creator>daXtreme</dc:creator>
    <dc:date>2022-09-02T18:44:16Z</dc:date>
    <item>
      <title>Sales YTD based on Week Selection</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sales-YTD-based-on-Week-Selection/m-p/2742500#M84339</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a week filter on top of the report and then a simple bar chart that shows me the sales per month.&lt;/P&gt;
&lt;P&gt;Based on the week selection I would like to display all sales YTD until this week.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This approach is not working:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;SalesYTD = 
    CALCULATE (
        [Sales],
        FILTER (
            ALL ( 'Calendar' ),
            'Calendar'[Year] = MAX ( 'Calendar'[Year] )
                &amp;amp;&amp;amp; 'Calendar'[Week] &amp;lt;= MAX ( 'Calendar'[Week] )
        )
    )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This measure shows me the YTD volume based on the current month. The total sum is just displayed in the last month. But I would like to get all months display with the individual sales.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Sep 2022 06:53:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sales-YTD-based-on-Week-Selection/m-p/2742500#M84339</guid>
      <dc:creator>joshua1990</dc:creator>
      <dc:date>2022-09-02T06:53:30Z</dc:date>
    </item>
    <item>
      <title>Re: Sales YTD based on Week Selection</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sales-YTD-based-on-Week-Selection/m-p/2742850#M84355</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;Sales YTD =
var LastVisibleDate = MAX( 'Calendar'[Date] )
var CurrentYear = MAX( 'Calendar'[Year] ) // Year must be integer
var Result = 
    CALCULATE(
        [Sales],
        'Calendar'[Date] &amp;lt;= LastVisibleDate,
        'Calendar'[Year] = CurrentYear,
        REMOVEFILTERS( 'Calendar' )
    )
return
    Result
    
// or... if your 'Calendar' is a proper one:

Sales YTD =
CALCULATE(
    [Sales],
    DATESYTD( 'Calendar'[Date] )
)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this is not what you want, then please clarify what you mean by:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;"This measure shows me the YTD volume based on the current month. The total sum is just displayed in the last month. But I would like to get all months display with the individual sales."&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could do with some picture.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Sep 2022 08:31:33 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sales-YTD-based-on-Week-Selection/m-p/2742850#M84355</guid>
      <dc:creator>daXtreme</dc:creator>
      <dc:date>2022-09-02T08:31:33Z</dc:date>
    </item>
    <item>
      <title>Re: Sales YTD based on Week Selection</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sales-YTD-based-on-Week-Selection/m-p/2743269#M84384</link>
      <description>&lt;P&gt;Thanks a lot for your support&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="349489" data-lia-user-login="daXtreme" class="lia-mention lia-mention-user"&gt;daXtreme&lt;/a&gt;&amp;nbsp;:&lt;/P&gt;
&lt;P&gt;This is the picture without a Week Filter / Slicer&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;And this is the picture when I select Week 35 for instance:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When a week filter is applied, then I would like to get the YTD volume per Month until this MAX week.&lt;/P&gt;
&lt;P&gt;Currently it is summed up as you can see in the picture above.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Sep 2022 10:26:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sales-YTD-based-on-Week-Selection/m-p/2743269#M84384</guid>
      <dc:creator>joshua1990</dc:creator>
      <dc:date>2022-09-02T10:26:30Z</dc:date>
    </item>
    <item>
      <title>Re: Sales YTD based on Week Selection</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sales-YTD-based-on-Week-Selection/m-p/2743291#M84389</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="92006" data-lia-user-login="joshua1990" class="lia-mention lia-mention-user"&gt;joshua1990&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To do what you want you cannot put the dates on the x-axis as you do right now because if you filter the calendar (from which you've taken the periods), the x-axis &lt;STRONG&gt;will also get filtered&lt;/STRONG&gt; and DAX has nothing to do with this; that's how PBI works. You have to have a time axis that's independent of anything else, in a word: disconnected. Then you drop any of the time periods from the new time dimension on the visual and create a measure that works with just this table. So, if you want to make some pieces of time visible (in your case, from the beginning of the year up to and including the month that your week is part of), the measure should return a number; if you want to hide some parts of the axis, you just return blank. This is how you must set it all up.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Sep 2022 10:36:46 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sales-YTD-based-on-Week-Selection/m-p/2743291#M84389</guid>
      <dc:creator>daXtreme</dc:creator>
      <dc:date>2022-09-02T10:36:46Z</dc:date>
    </item>
    <item>
      <title>Re: Sales YTD based on Week Selection</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sales-YTD-based-on-Week-Selection/m-p/2743465#M84412</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="349489" data-lia-user-login="daXtreme" class="lia-mention lia-mention-user"&gt;daXtreme&lt;/a&gt;&amp;nbsp;: Thanks a lot. I understand the concept with the disconnected table, but I don't get the point how to create an appropriate measure.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Sep 2022 12:05:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sales-YTD-based-on-Week-Selection/m-p/2743465#M84412</guid>
      <dc:creator>joshua1990</dc:creator>
      <dc:date>2022-09-02T12:05:26Z</dc:date>
    </item>
    <item>
      <title>Re: Sales YTD based on Week Selection</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sales-YTD-based-on-Week-Selection/m-p/2744262#M84482</link>
      <description>&lt;P&gt;Well, just start working on it and you'll see the point immediately &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; Just remember that when a measure returns a BLANK for a dimension attribute's value, the attribute gets hidden from the user's view.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Sep 2022 18:44:16 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sales-YTD-based-on-Week-Selection/m-p/2744262#M84482</guid>
      <dc:creator>daXtreme</dc:creator>
      <dc:date>2022-09-02T18:44:16Z</dc:date>
    </item>
    <item>
      <title>Re: Sales YTD based on Week Selection</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sales-YTD-based-on-Week-Selection/m-p/2744663#M84500</link>
      <description>&lt;P&gt;I found a solution but it is not perfect. It will display BLANK(), if the actual measure is blank as well. A better solution would be to limit the second calendar table based on LastVisibleDate but I don't know how. Do you have an idea?&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Sales YTD =
var LastVisibleDate = MAX( 'Calendar'[Date] )
var CurrentYear = MAX( 'Calendar'[Year] ) // Year must be integer
var Result = 
    CALCULATE(
        [Sales],
        'Calendar'[Date] &amp;lt;= LastVisibleDate,
        'Calendar'[Year] = CurrentYear,
        REMOVEFILTERS( 'Calendar' )
    )
return
    IF(ISBLANK(Result), BLANK(),Result)&lt;/LI-CODE&gt;</description>
      <pubDate>Sat, 03 Sep 2022 09:20:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sales-YTD-based-on-Week-Selection/m-p/2744663#M84500</guid>
      <dc:creator>joshua1990</dc:creator>
      <dc:date>2022-09-03T09:20:38Z</dc:date>
    </item>
    <item>
      <title>Re: Sales YTD based on Week Selection</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sales-YTD-based-on-Week-Selection/m-p/2744669#M84501</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="92006" data-lia-user-login="joshua1990" class="lia-mention lia-mention-user"&gt;joshua1990&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is something you should not write:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;IF(ISBLANK(Result), BLANK(),Result)&lt;/LI-CODE&gt;
&lt;P&gt;Have you really read this statement? What does it say? In English: If the Result is blank, return blank; otherwise, return Result. So, it's exactly the same as:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Result&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;I'll create a simple model to show you how you should deal with the problem at hand. Bear with me, please.&lt;/P&gt;</description>
      <pubDate>Sat, 03 Sep 2022 09:46:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sales-YTD-based-on-Week-Selection/m-p/2744669#M84501</guid>
      <dc:creator>daXtreme</dc:creator>
      <dc:date>2022-09-03T09:46:44Z</dc:date>
    </item>
    <item>
      <title>Re: Sales YTD based on Week Selection</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sales-YTD-based-on-Week-Selection/m-p/2744717#M84504</link>
      <description>&lt;P&gt;Attached is a sketch for the solution...&lt;/P&gt;</description>
      <pubDate>Sat, 03 Sep 2022 11:10:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sales-YTD-based-on-Week-Selection/m-p/2744717#M84504</guid>
      <dc:creator>daXtreme</dc:creator>
      <dc:date>2022-09-03T11:10:26Z</dc:date>
    </item>
    <item>
      <title>Re: Sales YTD based on Week Selection</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sales-YTD-based-on-Week-Selection/m-p/2744750#M84511</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="349489" data-lia-user-login="daXtreme" class="lia-mention lia-mention-user"&gt;daXtreme&lt;/a&gt;&amp;nbsp;: Thanks a lot, now I got it! Would you take the same approach if the report contains 15 measures to be displayed like this? So 15 different measures displayed in the same way just on multiple pages.&lt;/P&gt;</description>
      <pubDate>Sat, 03 Sep 2022 12:13:27 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sales-YTD-based-on-Week-Selection/m-p/2744750#M84511</guid>
      <dc:creator>joshua1990</dc:creator>
      <dc:date>2022-09-03T12:13:27Z</dc:date>
    </item>
    <item>
      <title>Re: Sales YTD based on Week Selection</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sales-YTD-based-on-Week-Selection/m-p/2745175#M84540</link>
      <description>&lt;P&gt;Hi there.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yes, probably. Whether or not you need to do what I've done in the file depends on your needs. If you want to be able to select a piece of time (like a week, say), and show &lt;STRONG&gt;many other&lt;/STRONG&gt; pieces of time depending on the selection, then yes, you have to have an independent time axis and measures that will work with it. Of course, you can decrease the number of measures by employing calculation groups but that requires some knowledge of calculation groups (you can learn this on &lt;A href="http://www.sqlbi.com" target="_blank"&gt;www.sqlbi.com&lt;/A&gt;) and using the Tabular Editor. One other technique comes to my mind and it's illustrated&amp;nbsp;&lt;STRONG&gt;&lt;A href="https://youtu.be/d8Rm7dwM6gc" target="_blank" rel="noopener"&gt;here&lt;/A&gt;&amp;nbsp;&lt;/STRONG&gt;by Alberto Ferrari but it might not be as versatile as the one I've shown you. But it might be what you want, so please check it out.&lt;/P&gt;</description>
      <pubDate>Sat, 03 Sep 2022 20:26:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sales-YTD-based-on-Week-Selection/m-p/2745175#M84540</guid>
      <dc:creator>daXtreme</dc:creator>
      <dc:date>2022-09-03T20:26:03Z</dc:date>
    </item>
    <item>
      <title>Re: Sales YTD based on Week Selection</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sales-YTD-based-on-Week-Selection/m-p/2747737#M84685</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="349489" data-lia-user-login="daXtreme" class="lia-mention lia-mention-user"&gt;daXtreme&lt;/a&gt;&amp;nbsp;: Thank you so much for your support and detailed explenation. This helps much!&lt;/P&gt;
&lt;P&gt;I will take a closer look at calculation groups.&lt;/P&gt;
&lt;P&gt;I just tried to leverage your approach for a MTD approach, but it is not running yet. Do you know why?&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Sales MTD = 
var DatesLastDate = MAX( 'Calendar'[Date] )
var DatesVisibleMonth = SELECTEDVALUE( 'Calendar'[MonthOffset], -1)
var TimeAxisVisibleMonth = SELECTEDVALUE( 'Calendar 2'[MonthOffset] )
var TimeAxisLastVisibleDate = MAX( 'Calendar 2'[Date] )
var TimeAxisFirstVisibleDate = MIN( 'Calendar 2'[Date] )
var ShouldCalculate = 
    and(
        DatesVisibleMonth = TimeAxisVisibleMonth,
        TimeAxisFirstVisibleDate &amp;lt;= DatesLastDate
    )
var Output = 
    if( ShouldCalculate,
        CALCULATE(
            [Sales],
            'Calendar'[Date] &amp;lt;= TimeAxisLastVisibleDate
        )
    )
return
    Output &lt;/LI-CODE&gt;
&lt;P&gt;I just changed the Year to MonthOffset, but I get nothing displayed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Sep 2022 12:12:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sales-YTD-based-on-Week-Selection/m-p/2747737#M84685</guid>
      <dc:creator>joshua1990</dc:creator>
      <dc:date>2022-09-05T12:12:43Z</dc:date>
    </item>
    <item>
      <title>Re: Sales YTD based on Week Selection</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sales-YTD-based-on-Week-Selection/m-p/2748184#M84717</link>
      <description>&lt;P&gt;No idea. I'd need the data itself to have a look. But I'd encourage you to really, really, really watch this: "&lt;STRONG&gt;&lt;A href="https://youtu.be/d8Rm7dwM6gc" target="_blank" rel="noopener nofollow noreferrer"&gt;here&lt;/A&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;SPAN&gt;by Alberto Ferrari." You'll find a different technique that may be more relevant and maybe even easier to leverage.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Sep 2022 15:38:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sales-YTD-based-on-Week-Selection/m-p/2748184#M84717</guid>
      <dc:creator>daXtreme</dc:creator>
      <dc:date>2022-09-05T15:38:18Z</dc:date>
    </item>
  </channel>
</rss>

