<?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: Power Pivot - Wrong Results when using MAX of DATE in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Power-Pivot-Wrong-Results-when-using-MAX-of-DATE/m-p/4149477#M164885</link>
    <description>&lt;P&gt;This gives me a SEMANTIC ERROR - thanks for trying though.&lt;/P&gt;&lt;P&gt;I realise how difficult it is when someone is just describing what they want.&lt;/P&gt;&lt;P&gt;I've got a work around now using a calendar table that only runs upto the latest week in the data&lt;/P&gt;</description>
    <pubDate>Fri, 13 Sep 2024 12:43:36 GMT</pubDate>
    <dc:creator>matratus28</dc:creator>
    <dc:date>2024-09-13T12:43:36Z</dc:date>
    <item>
      <title>Power Pivot - Wrong Results when using MAX of DATE</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Power-Pivot-Wrong-Results-when-using-MAX-of-DATE/m-p/4147561#M164814</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;This might not be enough detail, but I have sales and volume data (t_volumes) linked to a calendar table (t_calendar) in Power Pivot.&lt;/P&gt;&lt;P&gt;The t_volumes data is at week, customer and product level.&lt;BR /&gt;There is also a t_product table linked to the T_volumes table, that contains all my product categories, unit of purchase etc&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I hard code the lastest week into my DAX I get the correct results in my Pivot table (when pulling in Category out of my t_product table too):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;This code works:&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;!--  StartFragment   --&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;SPAN class=""&gt;HCLatestWeekVolumes:=&lt;/SPAN&gt;&lt;SPAN class=""&gt;CALCULATE&lt;/SPAN&gt;&lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;SPAN class=""&gt;SUM&lt;/SPAN&gt;&lt;SPAN class=""&gt;(t_volumes[Eaches]), &lt;/SPAN&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;SPAN class=""&gt;t_calendar[Long week] = 202522)&lt;/SPAN&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;&lt;SPAN class=""&gt;This code doesn't work&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;&lt;SPAN class=""&gt;&lt;!--  StartFragment   --&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;SPAN class=""&gt;LatestWeekVolumes:=&lt;/SPAN&gt;&lt;SPAN class=""&gt;VAR&lt;/SPAN&gt; &lt;SPAN class=""&gt;LatestWeek&lt;/SPAN&gt;&lt;SPAN class=""&gt; = &lt;/SPAN&gt;&lt;SPAN class=""&gt;MAX&lt;/SPAN&gt;&lt;SPAN class=""&gt;(t_volumes[Long week])&lt;/SPAN&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;SPAN class=""&gt;RETURN&lt;/SPAN&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;SPAN class=""&gt;CALCULATE&lt;/SPAN&gt;&lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;SPAN class=""&gt;SUM&lt;/SPAN&gt;&lt;SPAN class=""&gt;(t_volumes[Eaches]), &lt;/SPAN&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;SPAN class=""&gt;t_calendar[Long week] = &lt;/SPAN&gt;&lt;SPAN class=""&gt;LatestWeek&lt;/SPAN&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;SPAN class=""&gt;)&lt;/SPAN&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&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;&lt;SPAN class=""&gt;I've played around with DAX containing the MAX function but I can't get it to work properly - can anyone help ? Thanks&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;&lt;SPAN class=""&gt;&lt;!--  EndFragment   --&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/U&gt;&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;!--  EndFragment   --&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Sep 2024 14:58:52 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Power-Pivot-Wrong-Results-when-using-MAX-of-DATE/m-p/4147561#M164814</guid>
      <dc:creator>matratus28</dc:creator>
      <dc:date>2024-09-12T14:58:52Z</dc:date>
    </item>
    <item>
      <title>Re: Power Pivot - Wrong Results when using MAX of DATE</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Power-Pivot-Wrong-Results-when-using-MAX-of-DATE/m-p/4147597#M164816</link>
      <description>&lt;P&gt;Try this measure&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;LatestWeekVolumes :=
VAR LatestWeek = MAX(t_calendar[Long week])
RETURN
    CALCULATE(
        SUM(t_volumes[Eaches]),
        t_calendar[Long week] = LatestWeek
    )&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 12 Sep 2024 15:10:23 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Power-Pivot-Wrong-Results-when-using-MAX-of-DATE/m-p/4147597#M164816</guid>
      <dc:creator>aduguid</dc:creator>
      <dc:date>2024-09-12T15:10:23Z</dc:date>
    </item>
    <item>
      <title>Re: Power Pivot - Wrong Results when using MAX of DATE</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Power-Pivot-Wrong-Results-when-using-MAX-of-DATE/m-p/4147797#M164826</link>
      <description>&lt;P&gt;I think what is happening is that when I bring in total volumes to my pivot table then the figure is correct.&lt;/P&gt;&lt;P&gt;But if I bring in another field to split the volumes - in this case Core List Group - then the pivot gives me the latest weeks volumes for each Group with sales in the latest week, but if there were no sales in the latest week then it gives me sales for that Group from the last week that it had sales.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any idea how to get round that?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Sep 2024 16:46:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Power-Pivot-Wrong-Results-when-using-MAX-of-DATE/m-p/4147797#M164826</guid>
      <dc:creator>matratus28</dc:creator>
      <dc:date>2024-09-12T16:46:44Z</dc:date>
    </item>
    <item>
      <title>Re: Power Pivot - Wrong Results when using MAX of DATE</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Power-Pivot-Wrong-Results-when-using-MAX-of-DATE/m-p/4148078#M164838</link>
      <description>&lt;P&gt;Are you trying to calculate the previous week?&lt;/P&gt;</description>
      <pubDate>Thu, 12 Sep 2024 22:00:36 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Power-Pivot-Wrong-Results-when-using-MAX-of-DATE/m-p/4148078#M164838</guid>
      <dc:creator>aduguid</dc:creator>
      <dc:date>2024-09-12T22:00:36Z</dc:date>
    </item>
    <item>
      <title>Re: Power Pivot - Wrong Results when using MAX of DATE</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Power-Pivot-Wrong-Results-when-using-MAX-of-DATE/m-p/4148907#M164858</link>
      <description>&lt;P&gt;Yes - it will always be the previous week.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a "Week" column in YYYYWW format and a "First Day of Week" column in DD/MM/YYYY format&lt;/P&gt;</description>
      <pubDate>Fri, 13 Sep 2024 07:16:19 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Power-Pivot-Wrong-Results-when-using-MAX-of-DATE/m-p/4148907#M164858</guid>
      <dc:creator>matratus28</dc:creator>
      <dc:date>2024-09-13T07:16:19Z</dc:date>
    </item>
    <item>
      <title>Re: Power Pivot - Wrong Results when using MAX of DATE</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Power-Pivot-Wrong-Results-when-using-MAX-of-DATE/m-p/4149290#M164873</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="615168" data-lia-user-login="matratus28" class="lia-mention lia-mention-user"&gt;matratus28&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I&amp;nbsp; think the problem is that you use max for t_volume table's week column which doesn't work correct. you should use t_calendar table instead.&amp;nbsp;&lt;SPAN&gt;( note that the relation between t_volume and t_calendar should be single filter direction)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If this post helps, then I would appreciate a thumbs up&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;and mark it as the solution&amp;nbsp;to help the other members find it more quickly.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Sep 2024 10:20:36 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Power-Pivot-Wrong-Results-when-using-MAX-of-DATE/m-p/4149290#M164873</guid>
      <dc:creator>Selva-Salimi</dc:creator>
      <dc:date>2024-09-13T10:20:36Z</dc:date>
    </item>
    <item>
      <title>Re: Power Pivot - Wrong Results when using MAX of DATE</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Power-Pivot-Wrong-Results-when-using-MAX-of-DATE/m-p/4149421#M164878</link>
      <description>&lt;P&gt;Thanks for the reply - the dates in my t_calendar table go into the future so using the max for that table bring back 0 as the date hasn't passed yet and so there are no sales.&lt;/P&gt;&lt;P&gt;Maybe I should amend my query so that the calendar table refreshs each week but only upto the lastest week?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Sep 2024 12:05:21 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Power-Pivot-Wrong-Results-when-using-MAX-of-DATE/m-p/4149421#M164878</guid>
      <dc:creator>matratus28</dc:creator>
      <dc:date>2024-09-13T12:05:21Z</dc:date>
    </item>
    <item>
      <title>Re: Power Pivot - Wrong Results when using MAX of DATE</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Power-Pivot-Wrong-Results-when-using-MAX-of-DATE/m-p/4149447#M164881</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="615168" data-lia-user-login="matratus28" class="lia-mention lia-mention-user"&gt;matratus28&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;you have some solution to manage this. but it is not clear for me that did you want do select latest week based on any slicer selection? or is it based on todays date?&lt;/P&gt;</description>
      <pubDate>Fri, 13 Sep 2024 12:20:39 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Power-Pivot-Wrong-Results-when-using-MAX-of-DATE/m-p/4149447#M164881</guid>
      <dc:creator>Selva-Salimi</dc:creator>
      <dc:date>2024-09-13T12:20:39Z</dc:date>
    </item>
    <item>
      <title>Re: Power Pivot - Wrong Results when using MAX of DATE</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Power-Pivot-Wrong-Results-when-using-MAX-of-DATE/m-p/4149454#M164882</link>
      <description>&lt;P&gt;It's not based on slicer selection. It's based on the data in the data model. I want to calculate total volumes based on the last week but the last week is based on the latest date in the data that has been loaded.&lt;/P&gt;&lt;P&gt;The date format in YYYYWW&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So if there is volume for 202401, 202402 and 202403 - I just want volumes 202403&lt;/P&gt;</description>
      <pubDate>Fri, 13 Sep 2024 12:24:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Power-Pivot-Wrong-Results-when-using-MAX-of-DATE/m-p/4149454#M164882</guid>
      <dc:creator>matratus28</dc:creator>
      <dc:date>2024-09-13T12:24:43Z</dc:date>
    </item>
    <item>
      <title>Re: Power Pivot - Wrong Results when using MAX of DATE</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Power-Pivot-Wrong-Results-when-using-MAX-of-DATE/m-p/4149465#M164883</link>
      <description>&lt;P&gt;Ok, then you can write this to find max_date:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;CALCULATE( MAX(t_calendar[Date]), FILTER(t_calendar, CALCULATE(COUNTROWS(t_volume), t_volume[Date] = t_calendar[Date]) &amp;gt; 0))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If this post helps, then I would appreciate a thumbs up&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;and mark it as the solution&amp;nbsp;to help the other members find it more quickly.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Sep 2024 12:30:29 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Power-Pivot-Wrong-Results-when-using-MAX-of-DATE/m-p/4149465#M164883</guid>
      <dc:creator>Selva-Salimi</dc:creator>
      <dc:date>2024-09-13T12:30:29Z</dc:date>
    </item>
    <item>
      <title>Re: Power Pivot - Wrong Results when using MAX of DATE</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Power-Pivot-Wrong-Results-when-using-MAX-of-DATE/m-p/4149477#M164885</link>
      <description>&lt;P&gt;This gives me a SEMANTIC ERROR - thanks for trying though.&lt;/P&gt;&lt;P&gt;I realise how difficult it is when someone is just describing what they want.&lt;/P&gt;&lt;P&gt;I've got a work around now using a calendar table that only runs upto the latest week in the data&lt;/P&gt;</description>
      <pubDate>Fri, 13 Sep 2024 12:43:36 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Power-Pivot-Wrong-Results-when-using-MAX-of-DATE/m-p/4149477#M164885</guid>
      <dc:creator>matratus28</dc:creator>
      <dc:date>2024-09-13T12:43:36Z</dc:date>
    </item>
  </channel>
</rss>

