<?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: VAR with multiple values in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/VAR-with-multiple-values/m-p/858354#M6876</link>
    <description>&lt;P&gt;Hi Martyn, thanks for looking at this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried it but it's not quite working as the table will be rolled up most of the time (i.e. not showing the time data) &amp;amp; each row will almost always be for multpled weeks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you think there's something similar to SELECTEDVALUES that can deal with all selected values or a better way of trying to get values for the 'equivalent eek' last year?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Wed, 27 Nov 2019 10:04:53 GMT</pubDate>
    <dc:creator>365Sdx</dc:creator>
    <dc:date>2019-11-27T10:04:53Z</dc:date>
    <item>
      <title>VAR with multiple values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/VAR-with-multiple-values/m-p/853160#M6748</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm trying to get values for the same week last year. I can't seem to use the&amp;nbsp;&lt;SPAN&gt;SAMEPERIODLASTYEAR function as it takes it too literally &amp;amp; pulls in values for the same date last year instead of the week which is less clearly defined.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;(e.g. this week started on Mon 11th Nov 2019 but the 'same' week last year started on Mon 12th Nov 2018)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I've got a field for week number so was trying to use the following dax code:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Qty Sold (Prior Yr) = 
	VAR CurrentWeek = SELECTEDVALUE( Ref_Dates[Week of Year] )
	VAR CurrentYear = SELECTEDVALUE( Ref_Dates[Year] )
 
	RETURN
CALCULATE( [Qty Sold], 
    		FILTER( ALL( Ref_Dates ),
			Ref_Dates[Week of Year] = CurrentWeek &amp;amp;&amp;amp; Ref_Dates[Year] = CurrentYear - 1)) ​&lt;/LI-CODE&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;On the surface it worked, but then noticed it doesn't show a total (screenshot 1) &amp;amp; also that it doesn't show anything at all if I roll up the table (e.g to year in screenshot 2).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;screenshot 1&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;screenshot 2&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm not that familiar with dax but assuming it's got something to do with using SELECTEDVALUE which can only deal with ONE value &amp;amp; I'm not sure of an alternative to use MULTIPLE values (specifically only the ones the visual is filtered on).&lt;/P&gt;&lt;P&gt;Does anyone know a way I can modify the formula so that it shows roll up values &amp;amp; total values?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Appreciate your help.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Nov 2019 15:25:57 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/VAR-with-multiple-values/m-p/853160#M6748</guid>
      <dc:creator>365Sdx</dc:creator>
      <dc:date>2019-11-21T15:25:57Z</dc:date>
    </item>
    <item>
      <title>Re: VAR with multiple values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/VAR-with-multiple-values/m-p/853302#M6751</link>
      <description>&lt;P&gt;Hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="157924" data-lia-user-login="365Sdx" class="lia-mention lia-mention-user"&gt;365Sdx&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It's not possible to use Power BI's built in time intelligence functions with week based calendars.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You're right that SELECTEDVALUES can only handle a single value. If there is more than one value in the filter context, it will return BLANK() by default.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As such, you can test your CurrentWeek variable to see if it's value is BLANK() and if so, use a different calculation.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Example:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Qty Sold (Prior Yr) =
VAR CurrentWeek = SELECTEDVALUE ( Ref_Dates[Week of Year] )
VAR CurrentYear = SELECTEDVALUE ( Ref_Dates[Year] )
VAR Result =
    IF (
        NOT ( ISBLANK ( CurrentWeek ) ),
        CALCULATE (
            [Qty Sold],
            FILTER ( 
		ALL ( Ref_Dates ),
                Ref_Dates[Week of Year] = CurrentWeek 
		&amp;amp;&amp;amp; Ref_Dates[Year] = CurrentYear - 1
            )
        ),
        CALCULATE (
            [Qty Sold],
            FILTER (
		ALL ( Ref_Date ),
		Ref_Dates[Year] = CurrentYear - 1
	    )
        )
    )
RETURN
    Result&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This should return the total Qty Sold for the previous year against the 'Total' row in the matrix.&lt;/P&gt;&lt;P&gt;Note: if you place a filter on the week, this formula will still calculate the total Qty Sold for the previous year (i.e. it will ignore the filter applied on the week).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Martyn&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Nov 2019 16:40:28 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/VAR-with-multiple-values/m-p/853302#M6751</guid>
      <dc:creator>MartynRamsden</dc:creator>
      <dc:date>2019-11-21T16:40:28Z</dc:date>
    </item>
    <item>
      <title>Re: VAR with multiple values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/VAR-with-multiple-values/m-p/858354#M6876</link>
      <description>&lt;P&gt;Hi Martyn, thanks for looking at this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried it but it's not quite working as the table will be rolled up most of the time (i.e. not showing the time data) &amp;amp; each row will almost always be for multpled weeks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you think there's something similar to SELECTEDVALUES that can deal with all selected values or a better way of trying to get values for the 'equivalent eek' last year?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 27 Nov 2019 10:04:53 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/VAR-with-multiple-values/m-p/858354#M6876</guid>
      <dc:creator>365Sdx</dc:creator>
      <dc:date>2019-11-27T10:04:53Z</dc:date>
    </item>
    <item>
      <title>Re: VAR with multiple values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/VAR-with-multiple-values/m-p/858371#M6877</link>
      <description>&lt;P&gt;Hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="157924" data-lia-user-login="365Sdx" class="lia-mention lia-mention-user"&gt;365Sdx&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry that didn't work out for you.&lt;/P&gt;&lt;P&gt;There are a few other ways to tackle this but it's hard to recommend anything without fully understanding your data model.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Are you able to share your pbix? Make sure you remove any sensitive data before you do.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Martyn&lt;/P&gt;</description>
      <pubDate>Wed, 27 Nov 2019 10:28:20 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/VAR-with-multiple-values/m-p/858371#M6877</guid>
      <dc:creator>MartynRamsden</dc:creator>
      <dc:date>2019-11-27T10:28:20Z</dc:date>
    </item>
  </channel>
</rss>

