<?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: DATEDIFF between 2 dates in different tables in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DATEDIFF-between-2-dates-in-different-tables/m-p/2539170#M71482</link>
    <description>&lt;P&gt;Hi Tamer&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for responding.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is an expanded matrix showing the measure I'm expecting for the example I gave above.&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;But if I collapse any portion of the matrix it doesnt aggregate my measure.&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;</description>
    <pubDate>Wed, 25 May 2022 14:06:12 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2022-05-25T14:06:12Z</dc:date>
    <item>
      <title>DATEDIFF between 2 dates in different tables</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DATEDIFF-between-2-dates-in-different-tables/m-p/2538900#M71460</link>
      <description>&lt;P&gt;Hi this is my very first post and hoping someone can guide me in the right direction.&lt;/P&gt;&lt;P&gt;I'm trying to ascertain the DATEDIFF in minutes between 2 dates that are held in different tables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My first table contains operating theatre sessions.&amp;nbsp; I've created a composite key with the date of the session, the operating theatre, and which surgeon is scheduled to use it.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;My second table contains the patient-specific information for surgeries.&amp;nbsp; Again I created a composite key with the date of surgery, the operating theatre where the surgery was performed, and the surgeon who performed it.&amp;nbsp; I have also ascertained which patient per date, per operating room per surgeon was the first to be operated on.&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;Just to note, I also have a 'link' table with the data for each dimension (operating room and surgeon)&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I'm trying to measure is the number of minutes between the start of the session (START_DTTM from table 1) to the start of the first patient (Into Theatre DateTime from table 2) where the %Key matches.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After discovering various different functions, I thought I had a breakthrough with the below code but it doesn't work when trying to aggregate over a number of days/weeks obviously since I haven't defined that the&amp;nbsp;&lt;SPAN&gt;'&lt;/SPAN&gt;&lt;SPAN&gt;fact_service_point_sessions'[%Key] needs to equal the&amp;nbsp;'fact day therapy theatre events'[%Key].&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Minutes = &lt;/SPAN&gt;&lt;SPAN&gt;CALCULATE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;DATEDIFF&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;SELECTEDVALUE&lt;/SPAN&gt;&lt;SPAN&gt;('&lt;/SPAN&gt;&lt;SPAN&gt;fact_service_point_sessions'[START_DTTM]&lt;/SPAN&gt;&lt;SPAN&gt;),&lt;/SPAN&gt;&lt;SPAN&gt;SELECTEDVALUE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'fact day therapy theatre events'[Earliest Date]&lt;/SPAN&gt;&lt;SPAN&gt;),&lt;/SPAN&gt;&lt;SPAN&gt;MINUTE&lt;/SPAN&gt;&lt;SPAN&gt;),&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;'fact day therapy theatre events'[First Patient]&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;"First"&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Open to any and all suggestions/advice.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Thanks if you got this far!&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Ciara&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 25 May 2022 12:36:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DATEDIFF-between-2-dates-in-different-tables/m-p/2538900#M71460</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-05-25T12:36:13Z</dc:date>
    </item>
    <item>
      <title>Re: DATEDIFF between 2 dates in different tables</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DATEDIFF-between-2-dates-in-different-tables/m-p/2538949#M71466</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you please share a sample of the expected results?&lt;/P&gt;</description>
      <pubDate>Wed, 25 May 2022 12:54:08 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DATEDIFF-between-2-dates-in-different-tables/m-p/2538949#M71466</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-05-25T12:54:08Z</dc:date>
    </item>
    <item>
      <title>Re: DATEDIFF between 2 dates in different tables</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DATEDIFF-between-2-dates-in-different-tables/m-p/2539170#M71482</link>
      <description>&lt;P&gt;Hi Tamer&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for responding.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is an expanded matrix showing the measure I'm expecting for the example I gave above.&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;But if I collapse any portion of the matrix it doesnt aggregate my measure.&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;</description>
      <pubDate>Wed, 25 May 2022 14:06:12 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DATEDIFF-between-2-dates-in-different-tables/m-p/2539170#M71482</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-05-25T14:06:12Z</dc:date>
    </item>
    <item>
      <title>Re: DATEDIFF between 2 dates in different tables</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DATEDIFF-between-2-dates-in-different-tables/m-p/2539376#M71487</link>
      <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please use&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;Minutes =
SUMX (
    CROSSJOIN (
        SUMMARIZE ( 'Link Table', dim_date[Date], dim_date[Year] ),
        SUMMARIZE (
            'Link Table',
            'Link Table'[dim_professional_carer_key],
            'Link Table'[dim_service_points_key]
        )
    ),
    CALCULATE (
        DATEDIFF (
            SELECTEDVALUE ( 'fact_service_point_sessions'[START_DTTM] ),
            SELECTEDVALUE ( 'fact day therapy theatre events'[Earliest Date] ),
            MINUTE
        ),
        'fact day therapy theatre events'[First Patient] = "First"
    )
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 May 2022 15:49:02 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DATEDIFF-between-2-dates-in-different-tables/m-p/2539376#M71487</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-05-25T15:49:02Z</dc:date>
    </item>
    <item>
      <title>Re: DATEDIFF between 2 dates in different tables</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DATEDIFF-between-2-dates-in-different-tables/m-p/2541595#M71599</link>
      <description>&lt;P&gt;Thank you so much for all your help Tamer.&amp;nbsp; I couldn't have done it without you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 May 2022 13:51:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DATEDIFF-between-2-dates-in-different-tables/m-p/2541595#M71599</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-05-26T13:51:38Z</dc:date>
    </item>
  </channel>
</rss>

