<?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: ALL (Column) behavior issue in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/ALL-Column-behavior-issue/m-p/1048746#M14283</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="167623" data-lia-user-login="KevinW_SDP" class="lia-mention lia-mention-user"&gt;KevinW_SDP&lt;/a&gt; ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please share sample data with expected results (including the filters you were applying and not getting the right results).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ideally Time Intelligence functions should solve your problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers!&lt;BR /&gt;Vivek&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://www.vivran.in/" target="_blank"&gt;https://www.vivran.in/&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://www.linkedin.com/in/vivek-ranjan-063a1a17b/" target="_blank"&gt;Connect on LinkedIn&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Sun, 26 Apr 2020 03:07:59 GMT</pubDate>
    <dc:creator>vivran22</dc:creator>
    <dc:date>2020-04-26T03:07:59Z</dc:date>
    <item>
      <title>ALL (Column) behavior issue</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/ALL-Column-behavior-issue/m-p/1048684#M14281</link>
      <description>&lt;P&gt;I am working on some DAX and it is not working as I expect. I tried using some of the DAX functions to do this, but they weren't quite what I was needing. Also, I am doing this in SSAS which seems to have a very slight difference in support for newer DAX commands.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am working on creating a Prior Year To Date functionality, but the precanned TOTALYTD doesn't display results when certain filters are applied. Instead, I am trying to use the code below. The main problem I am having is I need to return all of the results from the Sales table with filters still there except for on the date fields as I want to apply a custom date filter as shown in the code below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Sales Amount PYTD:=

RETURN 
	SUMX(
		FILTER(
            ALL(Sales[invoiced_date]),
            YEAR('Sales'[invoiced_date]) = SELECTEDVALUE('- Date'[YearOrder]) - 1 &amp;amp;&amp;amp; MONTH('Sales'[invoiced_date]) &amp;lt;= SELECTEDVALUE('- Date'[MonthOfYearNumber])
		),
        [sales_amount]
	)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using&amp;nbsp;ALL(Sales[invoiced_date]) which according to the Microsoft documentation&amp;nbsp;&lt;A href="https://docs.microsoft.com/en-us/dax/allexcept-function-dax" target="_self"&gt;here,&lt;/A&gt; this code should "&lt;SPAN&gt;Removes all filters from the specified columns in the table; all other filters on other columns in the table still apply. All column arguments must come from the same table. The ALL(Column) variant is useful when you want to remove the context filters for one or more specific columns and to keep all other context filters." I interpret that as by using this in the manner I have, it should return all data in that table but remove the filter from the&amp;nbsp;Sales[invoiced_date] column.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem is, when I do this, Visual Studio is throwing a "Semantice Error: Column 'sales_amount' cannot be found or may not be used in this expression." Can anyone give me some insight on what I am doing wrong here?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance.&lt;/P&gt;</description>
      <pubDate>Sun, 26 Apr 2020 00:30:55 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/ALL-Column-behavior-issue/m-p/1048684#M14281</guid>
      <dc:creator>KevinW_SDP</dc:creator>
      <dc:date>2020-04-26T00:30:55Z</dc:date>
    </item>
    <item>
      <title>Re: ALL (Column) behavior issue</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/ALL-Column-behavior-issue/m-p/1048746#M14283</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="167623" data-lia-user-login="KevinW_SDP" class="lia-mention lia-mention-user"&gt;KevinW_SDP&lt;/a&gt; ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please share sample data with expected results (including the filters you were applying and not getting the right results).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ideally Time Intelligence functions should solve your problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers!&lt;BR /&gt;Vivek&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://www.vivran.in/" target="_blank"&gt;https://www.vivran.in/&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://www.linkedin.com/in/vivek-ranjan-063a1a17b/" target="_blank"&gt;Connect on LinkedIn&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 26 Apr 2020 03:07:59 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/ALL-Column-behavior-issue/m-p/1048746#M14283</guid>
      <dc:creator>vivran22</dc:creator>
      <dc:date>2020-04-26T03:07:59Z</dc:date>
    </item>
    <item>
      <title>Re: ALL (Column) behavior issue</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/ALL-Column-behavior-issue/m-p/1048759#M14284</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="167623" data-lia-user-login="KevinW_SDP" class="lia-mention lia-mention-user"&gt;KevinW_SDP&lt;/a&gt; , You can try YTD with following method. Prefer a date calendar do not use Date from fact.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;YTD QTY = TOTALYTD(Sum('order'[Qty]),'Date'[Date])
LYTD QTY = TOTALYTD(Sum('order'[Qty]),dateadd('Date'[Date],-1,year))
Previous Year = CALCULATE(SUM('order'[Qty]), PREVIOUSYEAR('Date'[Date]))

YTD QTY forced= 
var _max = today()
return
calculate(Sum('order'[Qty]),DATESYTD('Date'[Date]),'Date'[Date]&amp;lt;=_max)
//calculate(TOTALYTD(Sum('order'[Qty]),'Date'[Date]),filter('Date','Date'[Date]&amp;lt;=_max))

LYTD QTY forced= 
var _max = date(year(today())-1,month(today()),day(today()))
return
CALCULATE(Sum('order'[Qty]),DATESYTD(dateadd('Date'[Date],-1,year)),'Date'[Date]&amp;lt;=_max)
//TOTALYTD(Sum('order'[Qty]),dateadd('Date'[Date],-1,year),'Date'[Date]&amp;lt;=_max)

YTD QTY forced= 
var _max = maxx('order',[Order date])
return
calculate(Sum('order'[Qty]),DATESYTD('Date'[Date]),'Date'[Date]&amp;lt;=_max)
//calculate(TOTALYTD(Sum('order'[Qty]),'Date'[Date]),filter('Date','Date'[Date]&amp;lt;=_max))

LYTD QTY forced= 
var _max1 =maxx('order',[Order date])
var _max = date(year(_max1)-1,month(_max1),day(_max1))
return
CALCULATE(Sum('order'[Qty]),DATESYTD(dateadd('Date'[Date],-1,year)),'Date'[Date]&amp;lt;=_max)
//TOTALYTD(Sum('order'[Qty]),dateadd('Date'[Date],-1,year),'Date'[Date]&amp;lt;=_max)
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer : &lt;BR /&gt;&lt;A href="https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions" target="_blank"&gt;https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions&lt;/A&gt; &lt;BR /&gt;&lt;A href="https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi" target="_blank"&gt;https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/" target="_blank"&gt;https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 26 Apr 2020 04:08:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/ALL-Column-behavior-issue/m-p/1048759#M14284</guid>
      <dc:creator>amitchandak</dc:creator>
      <dc:date>2020-04-26T04:08:50Z</dc:date>
    </item>
    <item>
      <title>Re: ALL (Column) behavior issue</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/ALL-Column-behavior-issue/m-p/1048831#M14289</link>
      <description>Please, before you start creating DAX and models which are completely wrong and unmanageable, try to watch these first and then adhere to Best Practices. It'll help you stay sane.&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://www.youtube.com/watch?v=_quTwyvDfG0" target="_blank"&gt;https://www.youtube.com/watch?v=_quTwyvDfG0&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://www.youtube.com/watch?v=78d6mwR8GtA" target="_blank"&gt;https://www.youtube.com/watch?v=78d6mwR8GtA&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://www.sqlbi.com/tv/time-intelligence-in-microsoft-power-bi/" target="_blank"&gt;https://www.sqlbi.com/tv/time-intelligence-in-microsoft-power-bi/&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://radacad.com/basics-of-time-intelligence-in-dax-for-power-bi-year-to-date-quarter-to-date-month-to-date" target="_blank"&gt;https://radacad.com/basics-of-time-intelligence-in-dax-for-power-bi-year-to-date-quarter-to-date-month-to-date&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Best&lt;BR /&gt;D</description>
      <pubDate>Sun, 26 Apr 2020 08:27:29 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/ALL-Column-behavior-issue/m-p/1048831#M14289</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-04-26T08:27:29Z</dc:date>
    </item>
    <item>
      <title>Re: ALL (Column) behavior issue</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/ALL-Column-behavior-issue/m-p/1049000#M14298</link>
      <description>&lt;P&gt;Please read my original question. I have not got to the point of publishing this code because it throws an error in Visual Studio as mentioned at the end of the question. The problem is not the results of the query, but the fact that the documentation states one thing and when coding it, it is throwing an error stating it is not being used properly.&lt;/P&gt;</description>
      <pubDate>Sun, 26 Apr 2020 13:54:21 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/ALL-Column-behavior-issue/m-p/1049000#M14298</guid>
      <dc:creator>KevinW_SDP</dc:creator>
      <dc:date>2020-04-26T13:54:21Z</dc:date>
    </item>
    <item>
      <title>Re: ALL (Column) behavior issue</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/ALL-Column-behavior-issue/m-p/1049002#M14299</link>
      <description>&lt;P&gt;Thank you for the reply. Below is the code that ended up giving me what I am needing.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Sales Amount PYTD:=
var _max = DATE(YEAR(TODAY())-1,MONTH(TODAY()),DAY(TODAY()))

RETURN
    CALCULATE (
        Sum('Sales'[sales_amount]),
        DATESYTD(
            DATEADD('- Date'[Date], -1, YEAR)),
        '- Date'[Date] &amp;lt;=_max
    )&lt;/LI-CODE&gt;</description>
      <pubDate>Sun, 26 Apr 2020 14:04:36 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/ALL-Column-behavior-issue/m-p/1049002#M14299</guid>
      <dc:creator>KevinW_SDP</dc:creator>
      <dc:date>2020-04-26T14:04:36Z</dc:date>
    </item>
    <item>
      <title>Re: ALL (Column) behavior issue</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/ALL-Column-behavior-issue/m-p/1049009#M14302</link>
      <description>&lt;P&gt;Here is the insight you wanted.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First, sorry to say that but this code is flawed. This piece&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;var _max = DATE(YEAR(TODAY())-1,MONTH(TODAY()),DAY(TODAY()))&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;will be wrong if you stumble upon a leap year. Check it out.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Secondly,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Sales Amount PYTD :=
SUMX (
    FILTER (
        ALL ( Sales[invoiced_date] ),
        YEAR ( 'Sales'[invoiced_date] )
            = SELECTEDVALUE ( '- Date'[YearOrder] ) - 1
            &amp;amp;&amp;amp; MONTH ( 'Sales'[invoiced_date] )
                &amp;lt;= SELECTEDVALUE ( '- Date'[MonthOfYearNumber] )
    ),
    [sales_amount]
)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;gives you a semantic error because the table ALL( Sales[invoiced_date] ) has only one column: invoiced_date. And you are iterating over it trying to extract [sales_amount] which is not present in it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a question regarding your measure:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Sales Amount PYTD :=
VAR _max =
    DATE ( YEAR ( TODAY () ) - 1, MONTH ( TODAY () ), DAY ( TODAY () ) )
RETURN
    CALCULATE (
        SUM ( 'Sales'[sales_amount] ),
        DATESYTD ( DATEADD ( '- Date'[Date], -1, YEAR ) ),
        
        -- What is the purpose of this filter?
        '- Date'[Date] &amp;lt;= _max
    )&lt;/LI-CODE&gt;
&lt;P&gt;What's the purpose of the filter marked with my comment? The one with "... &amp;lt;= _max"? Does it in any way contribute to the calculation? 'Cause I think it does not. Can you please explain? Thanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best&lt;BR /&gt;D&lt;/P&gt;</description>
      <pubDate>Sun, 26 Apr 2020 14:24:58 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/ALL-Column-behavior-issue/m-p/1049009#M14302</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-04-26T14:24:58Z</dc:date>
    </item>
  </channel>
</rss>

