<?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: Previous week sales out of weekly data table in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-week-sales-out-of-weekly-data-table/m-p/3490500#M133634</link>
    <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="191221" data-lia-user-login="akfir" class="lia-mention lia-mention-user"&gt;akfir&lt;/a&gt;&amp;nbsp;try to provide more data to well reflect your situation.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 23 Oct 2023 06:25:26 GMT</pubDate>
    <dc:creator>FreemanZ</dc:creator>
    <dc:date>2023-10-23T06:25:26Z</dc:date>
    <item>
      <title>Previous week sales out of weekly data table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-week-sales-out-of-weekly-data-table/m-p/3488311#M133502</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;i have this data table of WEEKLY sales (by week number):&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;i have a measure of Sales = sum(Quantity), i wish to create :&lt;BR /&gt;1. a measure of sales for the previous week (please notice the situation that the previous week for week1 is week52/53 of the previous year).&lt;BR /&gt;2. a measure of average sales UNTIL the previous week (exc. the current one)&lt;BR /&gt;&lt;BR /&gt;thanks in advance,&lt;BR /&gt;Amit&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Oct 2023 17:06:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-week-sales-out-of-weekly-data-table/m-p/3488311#M133502</guid>
      <dc:creator>akfir</dc:creator>
      <dc:date>2023-10-20T17:06:17Z</dc:date>
    </item>
    <item>
      <title>Re: Previous week sales out of weekly data table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-week-sales-out-of-weekly-data-table/m-p/3490018#M133588</link>
      <description>&lt;LI-CODE lang="markup"&gt;please notice the situation that the previous week for week1 is week52/53 of the previous year&lt;/LI-CODE&gt;
&lt;P&gt;You need better week numbers. I'd recommend you take the day number and integer divide it by 7.&amp;nbsp; Then the "previous week"&amp;nbsp; is exactly weeknumber-1, always.&lt;/P&gt;</description>
      <pubDate>Sun, 22 Oct 2023 22:45:53 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-week-sales-out-of-weekly-data-table/m-p/3490018#M133588</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2023-10-22T22:45:53Z</dc:date>
    </item>
    <item>
      <title>Re: Previous week sales out of weekly data table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-week-sales-out-of-weekly-data-table/m-p/3490317#M133604</link>
      <description>&lt;P&gt;hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="191221" data-lia-user-login="akfir" class="lia-mention lia-mention-user"&gt;akfir&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Not sure if i fully get you. Inspired by Ibendlin's advice, i would suggest you try like:&lt;/P&gt;&lt;P&gt;1. supposing your sample data table looks like:&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Date&lt;/TD&gt;&lt;TD&gt;Quantity&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12/21/2022&lt;/TD&gt;&lt;TD&gt;100&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12/22/2022&lt;/TD&gt;&lt;TD&gt;200&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12/23/2022&lt;/TD&gt;&lt;TD&gt;300&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12/29/2022&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12/30/2022&lt;/TD&gt;&lt;TD&gt;20&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12/31/2022&lt;/TD&gt;&lt;TD&gt;30&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1/1/2023&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1/2/2023&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. try to have a dates table like below and relate it with the data table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Dates = 
ADDCOLUMNS(
    CALENDAR(MIN(data[Date]), MAX(data[Date])),
    "SerialWeekNumber", DATEDIFF(DATE(1900,1,1), [Date], WEEK)
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3. plot a table visual with Dates[Date] column and two measures like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Sales of PW = 
CALCULATE(
    SUM(data[Quantity]),
    FILTER(
        ALL(dates),
        dates[SerialWeekNumber] = MAX(dates[SerialWeekNumber]) -1
    )
)+0&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;History Week Average = 
VAR CurrentWeek = MAX(dates[SerialWeekNumber])
VAR StartWeek = MINX(ALL(Dates[SerialWeekNumber]), dates[SerialWeekNumber])
VAR HistoryTotal =
CALCULATE(
    SUM(data[quantity]),    
    FILTER(
        ALL(dates),
        dates[SerialWeekNumber] &amp;lt; CurrentWeek
    )
)
VAR HistoryWeeks =CurrentWeek - StartWeek
VAR result = DIVIDE(HistoryTotal, HistoryWeeks)
RETURN result&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&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>Mon, 23 Oct 2023 03:46:19 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-week-sales-out-of-weekly-data-table/m-p/3490317#M133604</guid>
      <dc:creator>FreemanZ</dc:creator>
      <dc:date>2023-10-23T03:46:19Z</dc:date>
    </item>
    <item>
      <title>Re: Previous week sales out of weekly data table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-week-sales-out-of-weekly-data-table/m-p/3490331#M133609</link>
      <description>&lt;P&gt;or if you prefer calculated columns (which is not advisible in most cases), try to add two calculated columns like:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Sales of PW = 
VAR _table =
    ADDCOLUMNS(
        ALL(data), 
        "SerialWeekNumber", DATEDIFF(DATE(1900,1,1), [Date], WEEK)
    )
VAR CurrentWeek = DATEDIFF(DATE(1900,1,1), [Date], WEEK)
VAR result = 
    SUMX(
        FILTER(
            _table,
        [SerialWeekNumber] = CurrentWeek -1
        ),
        data[Quantity]
    )
RETURN 
    result&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;History Week Average = 
VAR _table =
    ADDCOLUMNS(
        ALL(data),
        "SerialWeekNumber", DATEDIFF(DATE(1900,1,1), [Date], WEEK)
    )
VAR CurrentWeek = DATEDIFF(DATE(1900,1,1), [Date], WEEK)
VAR StartWeek = MINX(_table, [SerialWeekNumber])
VAR HistoryWeeks =CurrentWeek - StartWeek
VAR HistoryTotal =
SUMX(
    FILTER(
        _table,
        [SerialWeekNumber] &amp;lt; CurrentWeek
    ),
    data[quantity]
)
VAR result = DIVIDE(HistoryTotal, HistoryWeeks)
RETURN result&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>Mon, 23 Oct 2023 03:57:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-week-sales-out-of-weekly-data-table/m-p/3490331#M133609</guid>
      <dc:creator>FreemanZ</dc:creator>
      <dc:date>2023-10-23T03:57:30Z</dc:date>
    </item>
    <item>
      <title>Re: Previous week sales out of weekly data table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-week-sales-out-of-weekly-data-table/m-p/3490425#M133624</link>
      <description>&lt;P&gt;thanks for your reply.&lt;BR /&gt;but there are different channels, different products etc. for each if i wish i would like to calculate those measures and thats why i need measures and not calculated columns.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Oct 2023 05:46:45 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-week-sales-out-of-weekly-data-table/m-p/3490425#M133624</guid>
      <dc:creator>akfir</dc:creator>
      <dc:date>2023-10-23T05:46:45Z</dc:date>
    </item>
    <item>
      <title>Re: Previous week sales out of weekly data table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-week-sales-out-of-weekly-data-table/m-p/3490434#M133625</link>
      <description>&lt;P&gt;&lt;SPAN&gt;thanks for your reply.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;but there are different channels, different products etc. for each if i wish i would like to calculate those measures and thats why i need measures and not calculated columns.&lt;BR /&gt;&lt;/SPAN&gt;lets say i have a date column but it referrs to the first day of each week, as my data table is on a weekly basis with week numbers and not consecutive dates.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Oct 2023 05:49:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-week-sales-out-of-weekly-data-table/m-p/3490434#M133625</guid>
      <dc:creator>akfir</dc:creator>
      <dc:date>2023-10-23T05:49:30Z</dc:date>
    </item>
    <item>
      <title>Re: Previous week sales out of weekly data table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-week-sales-out-of-weekly-data-table/m-p/3490442#M133626</link>
      <description>&lt;P&gt;&lt;SPAN&gt;thanks for your reply.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;i didnt get it. could you please detail?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Oct 2023 05:51:33 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-week-sales-out-of-weekly-data-table/m-p/3490442#M133626</guid>
      <dc:creator>akfir</dc:creator>
      <dc:date>2023-10-23T05:51:33Z</dc:date>
    </item>
    <item>
      <title>Re: Previous week sales out of weekly data table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-week-sales-out-of-weekly-data-table/m-p/3490500#M133634</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="191221" data-lia-user-login="akfir" class="lia-mention lia-mention-user"&gt;akfir&lt;/a&gt;&amp;nbsp;try to provide more data to well reflect your situation.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Oct 2023 06:25:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-week-sales-out-of-weekly-data-table/m-p/3490500#M133634</guid>
      <dc:creator>FreemanZ</dc:creator>
      <dc:date>2023-10-23T06:25:26Z</dc:date>
    </item>
    <item>
      <title>Re: Previous week sales out of weekly data table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-week-sales-out-of-weekly-data-table/m-p/3490554#M133637</link>
      <description>&lt;P&gt;below is the matrix visual i need, with the measure result on the right. in addition as i mentioned originally, i need a measure calculates the history average (exc. current week sales)&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Oct 2023 06:54:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-week-sales-out-of-weekly-data-table/m-p/3490554#M133637</guid>
      <dc:creator>akfir</dc:creator>
      <dc:date>2023-10-23T06:54:30Z</dc:date>
    </item>
    <item>
      <title>Re: Previous week sales out of weekly data table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-week-sales-out-of-weekly-data-table/m-p/3490727#M133652</link>
      <description>&lt;P&gt;hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="191221" data-lia-user-login="akfir" class="lia-mention lia-mention-user"&gt;akfir&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;could you post the corresponding raw data of your expected vasual?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please also check this for data posting:&lt;/P&gt;&lt;P&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"&gt;https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Oct 2023 08:16:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-week-sales-out-of-weekly-data-table/m-p/3490727#M133652</guid>
      <dc:creator>FreemanZ</dc:creator>
      <dc:date>2023-10-23T08:16:32Z</dc:date>
    </item>
    <item>
      <title>Re: Previous week sales out of weekly data table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-week-sales-out-of-weekly-data-table/m-p/3490749#M133654</link>
      <description>&lt;P&gt;you can use the data from my original post. the numbers are a little different but it doesnt matter&lt;/P&gt;</description>
      <pubDate>Mon, 23 Oct 2023 08:24:12 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-week-sales-out-of-weekly-data-table/m-p/3490749#M133654</guid>
      <dc:creator>akfir</dc:creator>
      <dc:date>2023-10-23T08:24:12Z</dc:date>
    </item>
  </channel>
</rss>

