<?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 the last 20 weekdays in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/sales-the-last-20-weekdays/m-p/2964678#M98882</link>
    <description>&lt;P&gt;Thanks Neeko, now I can see what you are getting at, and it works. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Br,&lt;/P&gt;&lt;P&gt;jayjay0306&lt;/P&gt;</description>
    <pubDate>Tue, 13 Dec 2022 08:54:53 GMT</pubDate>
    <dc:creator>jayjay0306</dc:creator>
    <dc:date>2022-12-13T08:54:53Z</dc:date>
    <item>
      <title>sales the last 20 weekdays</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/sales-the-last-20-weekdays/m-p/2954546#M98113</link>
      <description>&lt;P&gt;Hi experts,&lt;/P&gt;&lt;P&gt;I hoope you can help me here:&lt;/P&gt;&lt;P&gt;I need to calculate the sales for a product in the last 20 week days. My problem is to frame the timeperiod to 20 weekdays, not only last 20 days(dates).&lt;/P&gt;&lt;P&gt;Here is my problem:&lt;/P&gt;&lt;P&gt;I have this table (for simplicity, it is just showing all products):&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As you can see I have tried to make a measure showing sales for the last 20 weekdays with this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Sales 20 days_Sum = CALCULATE(SUM('KPI Sell In'[Sales In Packs CY]),'Calendar'[CALENDAR_WEEK_END_IND]&amp;gt;0,DATESBETWEEN('Calendar'[Date],TODAY()-21,TODAY()-1))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but in this way I only get the latest 20 days from today (12-06-2022 - 11-17-2022) which is only 14 weekdays. Result: 9.103.800&lt;/P&gt;&lt;P&gt;What I need is the full 20 weekdays (in this case the period: 12-06-2022 - 11-09-2022) Result: 11.961.019&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The complexity is, that the number of weekdays changes depending on the day in week.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In short: How do I make a measure showing the sales for rolling 20 weekdays in this setup?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas wil be be greatly appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Br,&lt;/P&gt;&lt;P&gt;JayJay0306&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2022 16:09:34 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/sales-the-last-20-weekdays/m-p/2954546#M98113</guid>
      <dc:creator>jayjay0306</dc:creator>
      <dc:date>2022-12-07T16:09:34Z</dc:date>
    </item>
    <item>
      <title>Re: sales the last 20 weekdays</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/sales-the-last-20-weekdays/m-p/2954595#M98114</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="139186" data-lia-user-login="jayjay0306" class="lia-mention lia-mention-user"&gt;jayjay0306&lt;/a&gt;&amp;nbsp;Generally you do something like filter for the last 28 days but then filter that for WEEKDAY([Date],2) &amp;lt; 6 and then you could ADDCOLUMNS a simple counter for rows where the date is greater than or equal to the currrent date and then filter that down for this counter &amp;lt;= 20. Generally easier if you use a SUMX approach instead of CALCULATE.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2022 16:40:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/sales-the-last-20-weekdays/m-p/2954595#M98114</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2022-12-07T16:40:30Z</dc:date>
    </item>
    <item>
      <title>Re: sales the last 20 weekdays</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/sales-the-last-20-weekdays/m-p/2955117#M98158</link>
      <description>&lt;P&gt;Thanks Greg, are you takling about making a calculated table? I am not sure if I understand all what you're saying? Could you please show me some of the way?&lt;/P&gt;&lt;P&gt;thanks.&lt;/P&gt;&lt;P&gt;br,&lt;/P&gt;&lt;P&gt;jayjay0306&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2022 22:43:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/sales-the-last-20-weekdays/m-p/2955117#M98158</guid>
      <dc:creator>jayjay0306</dc:creator>
      <dc:date>2022-12-07T22:43:03Z</dc:date>
    </item>
    <item>
      <title>Re: sales the last 20 weekdays</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/sales-the-last-20-weekdays/m-p/2956135#M98205</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="139186" data-lia-user-login="jayjay0306" class="lia-mention lia-mention-user"&gt;jayjay0306&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;According to your description, here are my steps you can follow as a solution.&lt;/P&gt;
&lt;P&gt;(1) We can create a calculated column.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Weekday = var a=WEEKDAY('Table'[Date],2)
return IF(a&amp;lt;=5,"weekday","weekend")&lt;/LI-CODE&gt;
&lt;P&gt;(2)We can create a measure.&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Measure = var a=FILTER(ALL('Table'),[Date]&amp;lt;TODAY()&amp;amp;&amp;amp;'Table'[Weekday]="weekday")
var b=TOPN(20,a,[Date],DESC)
return SUMX(b,[Value])&lt;/LI-CODE&gt;
&lt;P&gt;(3) Then the result is as follows.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Neeko Tang&lt;/P&gt;
&lt;P&gt;If this post  &lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider &lt;STRONG&gt;&lt;EM&gt;Accept it as the solution&lt;/EM&gt;&lt;/STRONG&gt; to help the other members find it more quickly.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Dec 2022 08:52:14 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/sales-the-last-20-weekdays/m-p/2956135#M98205</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-12-08T08:52:14Z</dc:date>
    </item>
    <item>
      <title>Re: sales the last 20 weekdays</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/sales-the-last-20-weekdays/m-p/2956638#M98229</link>
      <description>&lt;P&gt;Thanks Neeko Tang,&lt;/P&gt;&lt;P&gt;We are close. However, it seem like it doesn't work as intended:&lt;/P&gt;&lt;P&gt;First of all, your "weekday"- calculation, I already have defined in the table (i.e. "WEEKEND_IND"), therefore I use this instead.&lt;/P&gt;&lt;P&gt;Hence, "your" calculation look like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;_Measure = 
var a=FILTER(ALL('Calendar'),'Calendar'[Date]&amp;amp;&amp;amp;'Calendar'[CALENDAR_WEEK_END_IND]=1)
var b=TOPN(20,a,'Calendar'[Date],DESC)
return 
SUMX(b,SUM('KPI Sell In'[Sales In Packs CY]))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, the result doesn't show the sum of sales for the last 20 days. It simply multiplies the sales each day with the number of days shown in TOPN() ?&lt;/P&gt;&lt;P&gt;example:&lt;/P&gt;&lt;P&gt;in the following I only pick one date (i.e. TOPN(1,....):&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;_Measure = 
var a=FILTER(ALL('Calendar'),'Calendar'[Date]&amp;amp;&amp;amp;'Calendar'[WEEKEND_IND]=1)
var b=TOPN(1,a,'Calendar'[Date],DESC)
return 
SUMX(b,SUM('Sales'[Sales]))&lt;/LI-CODE&gt;&lt;P&gt;Result:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;If we look at fx.the date "12-06-2022" we get the same sales amount on this date = 736.430.&lt;/P&gt;&lt;P&gt;This is fine.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But if I change the calcualtion to 2 days (i.e. TOPN(2,.....):&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;_Measure = 
var a=FILTER(ALL('Calendar'),'Calendar'[Date]&amp;amp;&amp;amp;'Calendar'[WEEKEND_IND]=1)
var b=TOPN(2,a,'Calendar'[Date],DESC)
return 
SUMX(b,SUM('Sales'[Sales]))&lt;/LI-CODE&gt;&lt;P&gt;Result:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;...I don't get the expected: 736.430+507368 = 1.243.798,&lt;/P&gt;&lt;P&gt;instead I get: 2 x 736.430 = 1.472.860 ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you know why?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Br,&lt;/P&gt;&lt;P&gt;Jayjay0306&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Dec 2022 12:01:36 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/sales-the-last-20-weekdays/m-p/2956638#M98229</guid>
      <dc:creator>jayjay0306</dc:creator>
      <dc:date>2022-12-08T12:01:36Z</dc:date>
    </item>
    <item>
      <title>Re: sales the last 20 weekdays</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/sales-the-last-20-weekdays/m-p/2958292#M98373</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="139186" data-lia-user-login="jayjay0306" class="lia-mention lia-mention-user"&gt;jayjay0306&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please create a calculated column in the sales table.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;CALENDAR_WEEK_END_IND = var a=WEEKDAY('Sales'[Date],2)
return IF(a&amp;lt;=5,1,0)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then create a measure in the sales table.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Measure = var a=FILTER(ALL('Sales'),[Date]&amp;lt;=SELECTEDVALUE('Sales'[Date])&amp;amp;&amp;amp;'Sales'[CALENDAR_WEEK_END_IND]=1)
var b=TOPN(2,a,[Date],DESC)
return SUMX(b,Sales[Sales])&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then the result is as follows.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Best Regards,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="background: white; margin: 7.5pt 0in 0in 0in;"&gt;&lt;SPAN&gt;Neeko Tang&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="background: white; margin: 7.5pt 0in 0in 0in;"&gt;&lt;SPAN&gt;If this post &lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider &lt;EM&gt;&lt;STRONG&gt;Accept it as the solution&lt;/STRONG&gt;&lt;/EM&gt; to help the other members find it more quickly.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Dec 2022 06:52:05 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/sales-the-last-20-weekdays/m-p/2958292#M98373</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-12-09T06:52:05Z</dc:date>
    </item>
    <item>
      <title>Re: sales the last 20 weekdays</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/sales-the-last-20-weekdays/m-p/2964678#M98882</link>
      <description>&lt;P&gt;Thanks Neeko, now I can see what you are getting at, and it works. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Br,&lt;/P&gt;&lt;P&gt;jayjay0306&lt;/P&gt;</description>
      <pubDate>Tue, 13 Dec 2022 08:54:53 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/sales-the-last-20-weekdays/m-p/2964678#M98882</guid>
      <dc:creator>jayjay0306</dc:creator>
      <dc:date>2022-12-13T08:54:53Z</dc:date>
    </item>
  </channel>
</rss>

