<?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: Quite frustrated - need help in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Quite-frustrated-need-help/m-p/1271111#M21411</link>
    <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="238895" data-lia-user-login="AviBI" class="lia-mention lia-mention-user"&gt;AviBI&lt;/a&gt; , see if these can help&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-Last-Week/ba-p/1051123" target="_blank"&gt;https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-Last-Week/ba-p/1051123&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://medium.com/@amitchandak.1978/power-bi-wtd-questions-time-intelligence-4-5-98c30fab69d3" target="_blank"&gt;https://medium.com/@amitchandak.1978/power-bi-wtd-questions-time-intelligence-4-5-98c30fab69d3&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;else&lt;/P&gt;
&lt;P&gt;Can you share sample data and sample output in table format? &lt;/P&gt;</description>
    <pubDate>Tue, 04 Aug 2020 09:58:36 GMT</pubDate>
    <dc:creator>amitchandak</dc:creator>
    <dc:date>2020-08-04T09:58:36Z</dc:date>
    <item>
      <title>Quite frustrated - need help</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Quite-frustrated-need-help/m-p/1271092#M21410</link>
      <description>&lt;P&gt;Hi all&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Trying to filter to Last week's items as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Period Lookup Table Filters Items Data Table - One to Many&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;LastWkItems = Calculate ([TotalItems] , Period[WeekofYr] =31 , Period[Year] = 2020 )&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Obviously, I do not want to keep hardcoded values the week number and year (31 &amp;amp; 2020 in this case) to avoid manual intervention every week. So I defined a couple of variable in the Period Lookup Table as follows:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;LastDate = Lastdate (Period[Date])&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;LastWk = WeekNum (LastDate)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Now when I used the variable in the above formula to replace the hardcoded 31, I get the following error:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;"A function Calculate has been used a True/False expression that is used as a table filter expression. This is not allowed"&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Pulling my hair out as to why this is not working when essentially I am replacing a hard number with a variable&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Appreciate the help guys&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="148838" data-lia-user-login="amitchandak" class="lia-mention lia-mention-user"&gt;amitchandak&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="313" data-lia-user-login="Greg_Deckler" class="lia-mention lia-mention-user"&gt;Greg_Deckler&lt;/a&gt;&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="507" data-lia-user-login="parry2k" class="lia-mention lia-mention-user"&gt;parry2k&lt;/a&gt;&amp;nbsp;Anonymous&lt;/a&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 04 Aug 2020 09:53:41 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Quite-frustrated-need-help/m-p/1271092#M21410</guid>
      <dc:creator>AviBI</dc:creator>
      <dc:date>2020-08-04T09:53:41Z</dc:date>
    </item>
    <item>
      <title>Re: Quite frustrated - need help</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Quite-frustrated-need-help/m-p/1271111#M21411</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="238895" data-lia-user-login="AviBI" class="lia-mention lia-mention-user"&gt;AviBI&lt;/a&gt; , see if these can help&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-Last-Week/ba-p/1051123" target="_blank"&gt;https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-Last-Week/ba-p/1051123&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://medium.com/@amitchandak.1978/power-bi-wtd-questions-time-intelligence-4-5-98c30fab69d3" target="_blank"&gt;https://medium.com/@amitchandak.1978/power-bi-wtd-questions-time-intelligence-4-5-98c30fab69d3&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;else&lt;/P&gt;
&lt;P&gt;Can you share sample data and sample output in table format? &lt;/P&gt;</description>
      <pubDate>Tue, 04 Aug 2020 09:58:36 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Quite-frustrated-need-help/m-p/1271111#M21411</guid>
      <dc:creator>amitchandak</dc:creator>
      <dc:date>2020-08-04T09:58:36Z</dc:date>
    </item>
    <item>
      <title>Re: Quite frustrated - need help</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Quite-frustrated-need-help/m-p/1271215#M21413</link>
      <description>&lt;P&gt;You are not showing us everything, &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="238895" data-lia-user-login="AviBI" class="lia-mention lia-mention-user"&gt;AviBI&lt;/a&gt;. What do you mean by "I defined a couple of variables in the Period Lookup Table"? This makes little sense. You can create variables in a formula, not in a table. Secondly, you can use variables in your measure formula instead of the hard-coded values in exactly the same places but the variables &lt;STRONG&gt;MUST&lt;/STRONG&gt; be defined in the measure itself, not outside. Remember that the syntax you're using is syntax sugar since all conditions under CALCULATE must be tables. So, this:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;calculate(
   [measure],
   T[Col] = a
)&lt;/LI-CODE&gt;&lt;P&gt;is always translated into:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;calculate(
   [measure],
   filter(
       all( T[Col] ),
       T[Col] = a
   )
)&lt;/LI-CODE&gt;&lt;P&gt;"a" must be a value, can't be a measure, for instance.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Aug 2020 10:26:28 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Quite-frustrated-need-help/m-p/1271215#M21413</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-08-04T10:26:28Z</dc:date>
    </item>
    <item>
      <title>Re: Quite frustrated - need help</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Quite-frustrated-need-help/m-p/1271295#M21416</link>
      <description>&lt;P&gt;&lt;img /&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the end result I am after - but I have acheived this using manual filters and I do not want to update the filters every week. This should be automated.&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;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Common field between Calendar &amp;amp; Data (Items Table) is "Period"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Measures:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;TotalItems = Calculate (Sum ('Items&amp;amp;Serv'[Items]), 'Items&amp;amp;Serv'[ItemType] = "Items")&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;ItemType column comprises 5 different categories but I am only interested in "Items" and hence I have used the measure to isolate the total for these&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;I am only interested in last weeks Items (week 31 of the year). The week numbers are available in the Calendar as a custom power query custom column&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;So I defined two measures:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;LastDate = Lastdate (Calendar[Date]) - this pulls the last date from the data table (Calendar table references the Items Table) in Power Query&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;LastWk = WeekNUM (LastDate) - This takes the LastDate measure above and calculates the Dax WeekNum&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;So far so good&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;img /&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;This is exactly what I need.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now in order to get to Last weeks items through a measure approach (not manual filters), this is how I think the measure should look like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;LastWeekItems = Calculate (TotalItems , WeekofYr = LastWk , Year = 2020)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This does not work. "Calculate" can not be used with True/False error&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This however works:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;LastWeekItems = Calculate (TotalItems, WeekofYr = 31, Year = 2020)&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;Now you may tell me that I am going about it all wrong which is fine. I just need the report to pickup the last week, and display the items on a daily basis (as shown above) and I need this to happen automatically based on the data and relationships (as above)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this gives all the info you required to help&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="148838" data-lia-user-login="amitchandak" class="lia-mention lia-mention-user"&gt;amitchandak&lt;/a&gt;&amp;nbsp;Anonymous&lt;/a&gt;&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="313" data-lia-user-login="Greg_Deckler" class="lia-mention lia-mention-user"&gt;Greg_Deckler&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Aug 2020 11:08:36 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Quite-frustrated-need-help/m-p/1271295#M21416</guid>
      <dc:creator>AviBI</dc:creator>
      <dc:date>2020-08-04T11:08:36Z</dc:date>
    </item>
    <item>
      <title>Re: Quite frustrated - need help</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Quite-frustrated-need-help/m-p/1271373#M21418</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;// Of course the one with hard-coded values works.
// I have already explained it in my first post.
// If you read it carefully, you'd know what to do...

[LastWeekItems] =
var __lastWeek = [LastWk]
return
	Calculate (
		[TotalItems],
		WeekofYr = __lastWeek,
		Year = 2020 // this should not be hard-coded
	)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Aug 2020 11:11:09 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Quite-frustrated-need-help/m-p/1271373#M21418</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-08-04T11:11:09Z</dc:date>
    </item>
    <item>
      <title>Re: Quite frustrated - need help</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Quite-frustrated-need-help/m-p/1271378#M21419</link>
      <description>&lt;P&gt;I did read your last post and did not quite understand as I am only used to defining straight forward measures (don't even know how to use "var" etc.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also understand that 2020 needs to be treated in a similar way as the week numbers. so I'll need to follow the same approach for the year as well&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a lot for your help. I will now try this&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;</description>
      <pubDate>Tue, 04 Aug 2020 11:15:07 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Quite-frustrated-need-help/m-p/1271378#M21419</guid>
      <dc:creator>AviBI</dc:creator>
      <dc:date>2020-08-04T11:15:07Z</dc:date>
    </item>
  </channel>
</rss>

