<?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 Virtual Table get values where Date is less than X in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Virtual-Table-get-values-where-Date-is-less-than-X/m-p/2559047#M72754</link>
    <description>&lt;P&gt;Hi everyone,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In part of a larger DAX I'm writing, I'm trying to isolate the VALUES(), or a virtual table with one column that has the dates prior to X.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example, instead of this, which only isolates the previous month:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;VAR previousMonthDates = PREVIOUSMONTH('Sales table'[date])&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;I am trying to have something like this, which isolates all dates prior to a given date:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;CALCULATE(VALUES('Date Table'[Date]), Filter('Date Table','Date Table'[Date]&amp;lt;DATE(2020,05,01))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;I am asking to receive the VALUES() of the column&amp;nbsp;Date Table'[Date] if they occur prior to 5/1/2020.. but I get this error:&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;The expression specified in the query is not a valid table expression.&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;My larger scale goal is to get the USER IDs of ppl that completed orders prior to a given date:&amp;nbsp;&lt;/DIV&gt;&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;VAR previousMonthsDates = CALCULATE(VALUES('Date Table'[Date]), Filter('Date Table','Date Table'[Date]&amp;lt;DATE(2020,05,01))

VAR previousMonthCustomers = CALCULATETABLE(VALUES(Orders[User Id]), 
    ALL('Date Table'[Date])
    , previousMonthsDates, USERELATIONSHIP(Orders[Completed At],'Date Table'[Date])
)​&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The intention of the above DAX is to get the VALUES() of the USER IDs for those that completed orders within the&amp;nbsp;previousMonthsDates&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas of how I can get arond this?&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 04 Jun 2022 20:55:02 GMT</pubDate>
    <dc:creator>ruesaint_denis</dc:creator>
    <dc:date>2022-06-04T20:55:02Z</dc:date>
    <item>
      <title>Virtual Table get values where Date is less than X</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Virtual-Table-get-values-where-Date-is-less-than-X/m-p/2559047#M72754</link>
      <description>&lt;P&gt;Hi everyone,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In part of a larger DAX I'm writing, I'm trying to isolate the VALUES(), or a virtual table with one column that has the dates prior to X.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example, instead of this, which only isolates the previous month:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;VAR previousMonthDates = PREVIOUSMONTH('Sales table'[date])&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;I am trying to have something like this, which isolates all dates prior to a given date:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;CALCULATE(VALUES('Date Table'[Date]), Filter('Date Table','Date Table'[Date]&amp;lt;DATE(2020,05,01))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;I am asking to receive the VALUES() of the column&amp;nbsp;Date Table'[Date] if they occur prior to 5/1/2020.. but I get this error:&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;The expression specified in the query is not a valid table expression.&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;My larger scale goal is to get the USER IDs of ppl that completed orders prior to a given date:&amp;nbsp;&lt;/DIV&gt;&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;VAR previousMonthsDates = CALCULATE(VALUES('Date Table'[Date]), Filter('Date Table','Date Table'[Date]&amp;lt;DATE(2020,05,01))

VAR previousMonthCustomers = CALCULATETABLE(VALUES(Orders[User Id]), 
    ALL('Date Table'[Date])
    , previousMonthsDates, USERELATIONSHIP(Orders[Completed At],'Date Table'[Date])
)​&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The intention of the above DAX is to get the VALUES() of the USER IDs for those that completed orders within the&amp;nbsp;previousMonthsDates&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas of how I can get arond this?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 04 Jun 2022 20:55:02 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Virtual-Table-get-values-where-Date-is-less-than-X/m-p/2559047#M72754</guid>
      <dc:creator>ruesaint_denis</dc:creator>
      <dc:date>2022-06-04T20:55:02Z</dc:date>
    </item>
    <item>
      <title>Re: Virtual Table get values where Date is less than X</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Virtual-Table-get-values-where-Date-is-less-than-X/m-p/2559089#M72756</link>
      <description>&lt;P&gt;BTW this worked when creating a calculated table, but when I try to create measure it gives me an error&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Calcuated Table that works to isolate the USER Ids that :&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;VAR currentCustomers = CALCULATETABLE(VALUES(Orders[User Id]), filter(Orders, Orders[Completed At]&amp;gt;=DATE(2020,04,01)&amp;amp;&amp;amp;Orders[Completed At]&amp;lt;DATE(2020,05,01)))
VAR previousMonthDates = SUMMARIZECOLUMNS ( 
    'Date Table'[Date], 
    FILTER('Date Table', 'Date Table'[Date]&amp;lt;DATE(2020,04,01))) 


VAR previousMonthCustomers = CALCULATETABLE(VALUES(Orders[User Id]), 
    ALL('Date Table'[Date])
    , previousMonthDates, USERELATIONSHIP(Orders[Completed At],'Date Table'[Date])
)

VAR repeatCustomersPreviousMonth = INTERSECT(currentCustomers, previousMonthCustomers)

RETURN 
repeatCustomersPreviousMonth

RETURN 
repeatCustomersPreviousMonth&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Measure throws error: &lt;SPAN&gt;SummarizeColumns() and AddMissingItems() may not be used in this context&lt;/SPAN&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;VAR currentCustomers = VALUES('Orders'[User Id])
VAR previousMonthDates = SUMMARIZECOLUMNS ( 
    'Date Table'[Date], 
    FILTER('Date Table', 'Date Table'[Date]&amp;lt;DATE(2020,05,01))) 


VAR previousMonthCustomers = CALCULATETABLE(VALUES(Orders[User Id]), 
    ALL('Date Table'[Date])
    , previousMonthDates, USERELATIONSHIP(Orders[Completed At],'Date Table'[Date])
)

VAR repeatCustomersPreviousMonth = INTERSECT(currentCustomers, previousMonthCustomers)

RETURN 
SUMX(repeatCustomersPreviousMonth, [Total Completed Sales]) &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the measure seems to work when I thorugh it in a card, but when I'm trying to get a table or a matrix it gives the error. This is my table:&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="lia-unicode-emoji" title=":loudly_crying_face:"&gt;😭&lt;/span&gt;I'm so close yet so far away, how can i address this?&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 04 Jun 2022 22:13:21 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Virtual-Table-get-values-where-Date-is-less-than-X/m-p/2559089#M72756</guid>
      <dc:creator>ruesaint_denis</dc:creator>
      <dc:date>2022-06-04T22:13:21Z</dc:date>
    </item>
    <item>
      <title>Re: Virtual Table get values where Date is less than X</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Virtual-Table-get-values-where-Date-is-less-than-X/m-p/2559279#M72762</link>
      <description>&lt;P&gt;Hello, I solved it, I used DATESBETWEEN&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;VAR MinDate = MIN ( 'Date Table'[Date] )-1
VAR currentCustomers = CALCULATETABLE(VALUES('Orders'[User Id]), Orders[Status]="Completed", USERELATIONSHIP(Orders[Completed At],'Date Table'[Date]))
VAR previousMonthDates =  DATESBETWEEN('Date Table'[Date], BLANK(),  MinDate) 


VAR previousMonthCustomers = CALCULATETABLE(distinct(Orders[User Id]),ALL('Date Table'[Date]), previousMonthDates, Orders[Status]="Completed", USERELATIONSHIP(Orders[Completed At],'Date Table'[Date])
)


VAR repeatCustomersPreviousMonth = INTERSECT(currentCustomers, previousMonthCustomers)

RETURN 
calculate(SUMX(repeatCustomersPreviousMonth, [Total Completed Sales]))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers!&lt;/P&gt;</description>
      <pubDate>Sun, 05 Jun 2022 04:54:47 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Virtual-Table-get-values-where-Date-is-less-than-X/m-p/2559279#M72762</guid>
      <dc:creator>ruesaint_denis</dc:creator>
      <dc:date>2022-06-05T04:54:47Z</dc:date>
    </item>
  </channel>
</rss>

