<?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: Having problems with previous weeks data in Desktop</title>
    <link>https://community.fabric.microsoft.com/t5/Desktop/Having-problems-with-previous-weeks-data/m-p/4268111#M1340887</link>
    <description>&lt;P&gt;Hello,&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/419403"&gt;@vsmn&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;here's a simple version:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;previousWeekTotal = 
var currentWeek = SELECTEDVALUE('Table'[week])
var previousWeek = MAXX(FILTER(ALL('Table'[week]), 'Table'[week] &amp;lt; currentWeek), 'Table'[week])
var result =  
CALCULATE(
    [total],
    'Table'[week] = previousWeek
)

return result&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I would scratch the "-1" check and just get any first value that is lower than current value (week).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="vojtechsima_0-1730651497041.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1193447i5426F23746FE9630/image-size/medium?v=v2&amp;amp;px=400" role="button" title="vojtechsima_0-1730651497041.png" alt="vojtechsima_0-1730651497041.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Alternative and that'S what you want, you can show blank if it's not the right week like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;previousWeekTotal = 
var currentWeek = SELECTEDVALUE('Table'[week])
var previousWeek = MAXX(FILTER(ALL('Table'[week]), 'Table'[week] &amp;lt; currentWeek), 'Table'[week])
var result =  
CALCULATE(
    [total],
    'Table'[week] = previousWeek
)
var isFollowing = IF(previousWeek = (currentWeek-1), result, BLANK())

return isFollowing&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="vojtechsima_1-1730651664965.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1193448iB9176E086989DA2F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="vojtechsima_1-1730651664965.png" alt="vojtechsima_1-1730651664965.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 03 Nov 2024 16:34:31 GMT</pubDate>
    <dc:creator>vojtechsima</dc:creator>
    <dc:date>2024-11-03T16:34:31Z</dc:date>
    <item>
      <title>Having problems with previous weeks data</title>
      <link>https://community.fabric.microsoft.com/t5/Desktop/Having-problems-with-previous-weeks-data/m-p/4268087#M1340873</link>
      <description>&lt;P&gt;I can't seem to get this working, has the result is somewhat incorrect.&lt;/P&gt;&lt;P&gt;I would like to display the previous week SUM or AVERAGE. There can be cases of non existent data in the previous week, for example:&lt;/P&gt;&lt;P&gt;Week 40 = 100&lt;/P&gt;&lt;P&gt;Week 39 = 101&lt;/P&gt;&lt;P&gt;Week 37 = 90&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In my table I have a column for the week number, and this is the measure I have:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Average Previous Week = 
VAR CurrentWeek = MAX(Carregar[Week of Year])
VAR CurrentTotal = AVERAGE(Carregar[Price])
VAR previous_price = 
    CALCULATE(
        AVERAGE(Carregar[Price]),
        FILTER(
            ALL(Carregar[Week of Year]),
            Carregar[Week of Year] = CurrentWeek - 1
    )
    )
RETURN
IF(
    ISBLANK(previous_price),
    CurrentTotal,previous_price
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;Somehow the result is innacurate:&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="vsmn_0-1730648389101.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1193438i3DF3E369F44EDA6A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="vsmn_0-1730648389101.png" alt="vsmn_0-1730648389101.png" /&gt;&lt;/span&gt;&lt;P&gt;What am I doing wrong?&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Sun, 03 Nov 2024 15:40:46 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Desktop/Having-problems-with-previous-weeks-data/m-p/4268087#M1340873</guid>
      <dc:creator>vsmn</dc:creator>
      <dc:date>2024-11-03T15:40:46Z</dc:date>
    </item>
    <item>
      <title>Re: Having problems with previous weeks data</title>
      <link>https://community.fabric.microsoft.com/t5/Desktop/Having-problems-with-previous-weeks-data/m-p/4268096#M1340878</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/419403"&gt;@vsmn&lt;/a&gt;&amp;nbsp;-&amp;nbsp;I see the problem with your measure. The issue is likely occurring because ALL(Carregar[Week of Year]) removes all filters on the week context, causing unexpected results.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;updated measure: can you please check with below&lt;/P&gt;
&lt;P&gt;Average Previous Week = &lt;BR /&gt;VAR CurrentWeek = MAX(Carregar[Week of Year])&lt;BR /&gt;VAR PreviousWeek =&lt;BR /&gt;MAXX(&lt;BR /&gt;FILTER(&lt;BR /&gt;ALL(Carregar),&lt;BR /&gt;Carregar[Week of Year] &amp;lt; CurrentWeek &amp;amp;&amp;amp; NOT(ISBLANK(Carregar[Price]))&lt;BR /&gt;),&lt;BR /&gt;Carregar[Week of Year]&lt;BR /&gt;)&lt;BR /&gt;VAR PreviousWeekPrice = &lt;BR /&gt;CALCULATE(&lt;BR /&gt;AVERAGE(Carregar[Price]),&lt;BR /&gt;Carregar[Week of Year] = PreviousWeek&lt;BR /&gt;)&lt;BR /&gt;RETURN&lt;BR /&gt;IF(&lt;BR /&gt;ISBLANK(PreviousWeekPrice),&lt;BR /&gt;BLANK(), // or use CurrentTotal if you want to default to current average&lt;BR /&gt;PreviousWeekPrice&lt;BR /&gt;)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps,try applying this measure, and let me know if it resolves the issue in your table.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 03 Nov 2024 16:11:12 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Desktop/Having-problems-with-previous-weeks-data/m-p/4268096#M1340878</guid>
      <dc:creator>rajendraongole1</dc:creator>
      <dc:date>2024-11-03T16:11:12Z</dc:date>
    </item>
    <item>
      <title>Re: Having problems with previous weeks data</title>
      <link>https://community.fabric.microsoft.com/t5/Desktop/Having-problems-with-previous-weeks-data/m-p/4268111#M1340887</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/419403"&gt;@vsmn&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;here's a simple version:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;previousWeekTotal = 
var currentWeek = SELECTEDVALUE('Table'[week])
var previousWeek = MAXX(FILTER(ALL('Table'[week]), 'Table'[week] &amp;lt; currentWeek), 'Table'[week])
var result =  
CALCULATE(
    [total],
    'Table'[week] = previousWeek
)

return result&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I would scratch the "-1" check and just get any first value that is lower than current value (week).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="vojtechsima_0-1730651497041.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1193447i5426F23746FE9630/image-size/medium?v=v2&amp;amp;px=400" role="button" title="vojtechsima_0-1730651497041.png" alt="vojtechsima_0-1730651497041.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Alternative and that'S what you want, you can show blank if it's not the right week like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;previousWeekTotal = 
var currentWeek = SELECTEDVALUE('Table'[week])
var previousWeek = MAXX(FILTER(ALL('Table'[week]), 'Table'[week] &amp;lt; currentWeek), 'Table'[week])
var result =  
CALCULATE(
    [total],
    'Table'[week] = previousWeek
)
var isFollowing = IF(previousWeek = (currentWeek-1), result, BLANK())

return isFollowing&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="vojtechsima_1-1730651664965.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1193448iB9176E086989DA2F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="vojtechsima_1-1730651664965.png" alt="vojtechsima_1-1730651664965.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 03 Nov 2024 16:34:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Desktop/Having-problems-with-previous-weeks-data/m-p/4268111#M1340887</guid>
      <dc:creator>vojtechsima</dc:creator>
      <dc:date>2024-11-03T16:34:31Z</dc:date>
    </item>
  </channel>
</rss>

