<?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: Lookup for 2 Date Range from 2 Tables in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookup-for-2-Date-Range-from-2-Tables/m-p/4849912#M185097</link>
    <description>&lt;P&gt;This might help you, it is showing how to differrent time ranges:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://youtu.be/TF0lPIYjJfs?si=OXWFJrFYG9NlbZ0W" target="_blank"&gt;https://youtu.be/TF0lPIYjJfs?si=OXWFJrFYG9NlbZ0W&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 14 Oct 2025 13:30:26 GMT</pubDate>
    <dc:creator>theov</dc:creator>
    <dc:date>2025-10-14T13:30:26Z</dc:date>
    <item>
      <title>Lookup for 2 Date Range from 2 Tables</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookup-for-2-Date-Range-from-2-Tables/m-p/4848903#M185060</link>
      <description>&lt;P&gt;Hello everyone!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Im trying to get the Event in Activity Table through a calculated column if the Activity Start and End is within the range of those on the Event Table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;Activity Table&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Activity&lt;/TD&gt;&lt;TD&gt;Start&lt;/TD&gt;&lt;TD&gt;End&lt;/TD&gt;&lt;TD&gt;Event &lt;STRONG&gt;(Desired Output)&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;07/03/2023 9:42&lt;/TD&gt;&lt;TD&gt;07/03/2023 23:59&lt;/TD&gt;&lt;TD&gt;No Event&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;05/01/2025 13:56&lt;/TD&gt;&lt;TD&gt;05/01/2025 23:59&lt;/TD&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;08/01/2025 11:14&lt;/TD&gt;&lt;TD&gt;08/01/2025 20:15&lt;/TD&gt;&lt;TD&gt;D&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&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;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;Event Table&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Event&lt;/TD&gt;&lt;TD&gt;Start&lt;/TD&gt;&lt;TD&gt;End&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;05/01/2025 14:56&lt;/TD&gt;&lt;TD&gt;05/01/2025 17:00&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;07/05/2023 9:42&lt;/TD&gt;&lt;TD&gt;07/05/2023 23:59&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;C&lt;/TD&gt;&lt;TD&gt;07/06/2023 7:00&lt;/TD&gt;&lt;TD&gt;07/06/2023 9:45&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;D&lt;/TD&gt;&lt;TD&gt;08/01/2025 11:14&lt;/TD&gt;&lt;TD&gt;08/01/2025 23:15&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Oct 2025 11:16:51 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookup-for-2-Date-Range-from-2-Tables/m-p/4848903#M185060</guid>
      <dc:creator>o-johnralphp</dc:creator>
      <dc:date>2025-10-13T11:16:51Z</dc:date>
    </item>
    <item>
      <title>Re: Lookup for 2 Date Range from 2 Tables</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookup-for-2-Date-Range-from-2-Tables/m-p/4848912#M185061</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="1369854" data-lia-user-login="o-johnralphp" class="lia-mention lia-mention-user"&gt;o-johnralphp&lt;/a&gt;, what should be the output if more than one event is found between the Start- and End-DateTime of your Activity Table?&lt;/P&gt;</description>
      <pubDate>Mon, 13 Oct 2025 11:28:20 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookup-for-2-Date-Range-from-2-Tables/m-p/4848912#M185061</guid>
      <dc:creator>KarinSzilagyi</dc:creator>
      <dc:date>2025-10-13T11:28:20Z</dc:date>
    </item>
    <item>
      <title>Re: Lookup for 2 Date Range from 2 Tables</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookup-for-2-Date-Range-from-2-Tables/m-p/4848934#M185062</link>
      <description>&lt;P&gt;&lt;A href="mailto:Hi@KarinSzilagyi," target="_blank"&gt;Hi @KarinSzilagyi,&lt;/A&gt;&lt;/P&gt;&lt;P&gt;If more than one event is found then the earliest event would be the output.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 13 Oct 2025 11:47:40 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookup-for-2-Date-Range-from-2-Tables/m-p/4848934#M185062</guid>
      <dc:creator>o-johnralphp</dc:creator>
      <dc:date>2025-10-13T11:47:40Z</dc:date>
    </item>
    <item>
      <title>Re: Lookup for 2 Date Range from 2 Tables</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookup-for-2-Date-Range-from-2-Tables/m-p/4849251#M185074</link>
      <description>&lt;P&gt;Hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="1369854" data-lia-user-login="o-johnralphp" class="lia-mention lia-mention-user"&gt;o-johnralphp&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You’re matching each Activity to the single Event whose time window fully contains the Activity window (Event.Start &amp;lt;= Activity.Start and Event.End &amp;gt;= Activity.End). A calculated column on Activity is fine for this.&lt;/P&gt;&lt;P&gt;Below are two DAX options:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;STRONG&gt;Containment match (your stated requirement):&lt;/STRONG&gt; Activity must be entirely within the Event.&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;Overlap match (if you later decide any overlap counts):&lt;/STRONG&gt; Activity overlaps Event in any way.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;I’ve also added a simple tie-breaker in case multiple Events fit: pick the one with the earliest Event.Start. You can tweak that if you prefer a different rule.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Event (calculated column) =
VAR aStart = Activity[Start]
VAR aEnd   = Activity[End]
VAR Candidates =
    FILTER (
        Event,                               -- or 'Events' if that's your table name
        Event[Start] &amp;lt;= aStart
            &amp;amp;&amp;amp; Event[End] &amp;gt;= aEnd            -- full containment
    )
VAR FirstMatch =
    TOPN ( 1, Candidates, Event[Start], ASC )   -- tie-break: earliest Event.Start
RETURN
COALESCE (
    CALCULATE ( SELECTEDVALUE ( Event[Event] ), FirstMatch ),
    "No Event"
)&lt;/LI-CODE&gt;&lt;P&gt;If instead you want &lt;STRONG&gt;any overlap&lt;/STRONG&gt; (not full containment), change the FILTER to:&lt;/P&gt;&lt;PRE&gt;FILTER (
    Events,
    Events[Start] &amp;lt; aEnd
        &amp;amp;&amp;amp; Events[End] &amp;gt; aStart            -- any overlap
)&lt;/PRE&gt;&lt;H3&gt;&amp;nbsp;&lt;/H3&gt;&lt;UL&gt;&lt;LI&gt;&lt;STRONG&gt;Why a calculated column?&lt;/STRONG&gt; You want a stable row-by-row lookup at refresh time. This avoids context complications from visuals.&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;Why not LOOKUPVALUE?&lt;/STRONG&gt; LOOKUPVALUE does equality matches; your requirement uses inequalities (&amp;lt;=, &amp;gt;=), so we filter Events instead.&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;Tie-breaking:&lt;/STRONG&gt; If multiple Events qualify, TOPN(1, ..., Events[Start], ASC) picks the earliest-starting Event. Replace with Events[End], DESC (latest ending) or another column if you prefer.&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;No match:&lt;/STRONG&gt; COALESCE(..., "No Event") outputs “No Event” when no Event window contains the Activity window.&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;Performance tip:&lt;/STRONG&gt; If Events is large, consider indexing/sorting in Power Query or materializing ranges (e.g., date keys) to reduce per-row scans. But for a modest Events table this pattern is fine.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;EDIT:&amp;nbsp;&lt;BR /&gt;Fixed the issue of the measure returning a table instead of a value for the calculate.&amp;nbsp;&lt;BR /&gt;Here is a link to the working file:&amp;nbsp;&lt;A href="https://drive.google.com/file/d/1e7219J5pMPaabFfmaJsxiXJsztwrxdki/view?usp=sharing" target="_blank"&gt;https://drive.google.com/file/d/1e7219J5pMPaabFfmaJsxiXJsztwrxdki/view?usp=sharing&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;If you found this helpful, consider giving some Kudos. If I answered your question or solved your problem, mark this post as the solution.&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Oct 2025 23:09:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookup-for-2-Date-Range-from-2-Tables/m-p/4849251#M185074</guid>
      <dc:creator>tayloramy</dc:creator>
      <dc:date>2025-10-14T23:09:38Z</dc:date>
    </item>
    <item>
      <title>Re: Lookup for 2 Date Range from 2 Tables</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookup-for-2-Date-Range-from-2-Tables/m-p/4849561#M185081</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="1340679" data-lia-user-login="tayloramy" class="lia-mention lia-mention-user"&gt;tayloramy&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the reply. I'm getting an error "The expression refers to multiple columns.Multiple columns cannot converted to a scalar value". I already formatted the necessary columns as Date/Time format.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Oct 2025 06:34:23 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookup-for-2-Date-Range-from-2-Tables/m-p/4849561#M185081</guid>
      <dc:creator>o-johnralphp</dc:creator>
      <dc:date>2025-10-14T06:34:23Z</dc:date>
    </item>
    <item>
      <title>Re: Lookup for 2 Date Range from 2 Tables</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookup-for-2-Date-Range-from-2-Tables/m-p/4849723#M185088</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="1369854" data-lia-user-login="o-johnralphp" class="lia-mention lia-mention-user"&gt;o-johnralphp&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;try this:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Event = 
VAR _start = Activity[Start]
VAR _end = Activity[End]
VAR filteredTable =
    FILTER ( Events, Events[Start] &amp;lt;= _end &amp;amp;&amp;amp; Events[End] &amp;gt;= _start )
VAR _TopN =
    --sort by [Start] in ascending order if there are multiple records then select the first one
    TOPN ( 1, filteredTable, [Start], ASC ) 
RETURN
    COALESCE ( MINX ( _TopN, [Event] ), "No event" )
&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Oct 2025 09:14:39 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookup-for-2-Date-Range-from-2-Tables/m-p/4849723#M185088</guid>
      <dc:creator>danextian</dc:creator>
      <dc:date>2025-10-14T09:14:39Z</dc:date>
    </item>
    <item>
      <title>Re: Lookup for 2 Date Range from 2 Tables</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookup-for-2-Date-Range-from-2-Tables/m-p/4849912#M185097</link>
      <description>&lt;P&gt;This might help you, it is showing how to differrent time ranges:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://youtu.be/TF0lPIYjJfs?si=OXWFJrFYG9NlbZ0W" target="_blank"&gt;https://youtu.be/TF0lPIYjJfs?si=OXWFJrFYG9NlbZ0W&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Oct 2025 13:30:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookup-for-2-Date-Range-from-2-Tables/m-p/4849912#M185097</guid>
      <dc:creator>theov</dc:creator>
      <dc:date>2025-10-14T13:30:26Z</dc:date>
    </item>
    <item>
      <title>Re: Lookup for 2 Date Range from 2 Tables</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookup-for-2-Date-Range-from-2-Tables/m-p/4850188#M185114</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="1369854" data-lia-user-login="o-johnralphp" class="lia-mention lia-mention-user"&gt;o-johnralphp&lt;/a&gt;,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have edited my reponse to correct that. I was working with a subset of data, only one event and one activity, so my results only returned one record as there was only one record to return. Note to self: Use more complete sample data.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Here is a link to the PBIC file with a working solution:&amp;nbsp;&lt;A href="https://drive.google.com/file/d/1e7219J5pMPaabFfmaJsxiXJsztwrxdki/view?usp=sharing" target="_blank"&gt;https://drive.google.com/file/d/1e7219J5pMPaabFfmaJsxiXJsztwrxdki/view?usp=sharing&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;EM&gt;&lt;STRONG&gt;If you found this helpful, consider giving some Kudos. If I answered your question or solved your problem, mark this post as the solution.&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Oct 2025 23:10:55 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookup-for-2-Date-Range-from-2-Tables/m-p/4850188#M185114</guid>
      <dc:creator>tayloramy</dc:creator>
      <dc:date>2025-10-14T23:10:55Z</dc:date>
    </item>
    <item>
      <title>Re: Lookup for 2 Date Range from 2 Tables</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookup-for-2-Date-Range-from-2-Tables/m-p/4850302#M185116</link>
      <description>&lt;P&gt;Thank you very much!!!&lt;/P&gt;</description>
      <pubDate>Wed, 15 Oct 2025 03:40:34 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookup-for-2-Date-Range-from-2-Tables/m-p/4850302#M185116</guid>
      <dc:creator>o-johnralphp</dc:creator>
      <dc:date>2025-10-15T03:40:34Z</dc:date>
    </item>
    <item>
      <title>Re: Lookup for 2 Date Range from 2 Tables</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookup-for-2-Date-Range-from-2-Tables/m-p/4850303#M185117</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="1340679" data-lia-user-login="tayloramy" class="lia-mention lia-mention-user"&gt;tayloramy&lt;/a&gt;&amp;nbsp;Thank you for your great help. Much appreciated.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Oct 2025 03:47:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookup-for-2-Date-Range-from-2-Tables/m-p/4850303#M185117</guid>
      <dc:creator>o-johnralphp</dc:creator>
      <dc:date>2025-10-15T03:47:18Z</dc:date>
    </item>
  </channel>
</rss>

