<?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 first date if available in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookup-first-date-if-available/m-p/2735430#M83881</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="317289" data-lia-user-login="tamerj1" class="lia-mention lia-mention-user"&gt;tamerj1&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Thank you for your reply. With slight modification on the table names (instead of "Messages (Outbound)" it should be the table "Messages") looks like it's getting the result, but only for the first inbound message.&lt;BR /&gt;&lt;BR /&gt;Is there a way to apply the logic to all inbound messages? You asked as well why the last row is blank, and that's because there was no outbound message after the last inbound.&lt;BR /&gt;&lt;BR /&gt;But imagining that there is one, this would be the desired outcome:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 30 Aug 2022 13:38:18 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2022-08-30T13:38:18Z</dc:date>
    <item>
      <title>Lookup first date if available</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookup-first-date-if-available/m-p/2732976#M83738</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a table with all the messages. These messages are by row, with columns indicating if it's an inbound message or outbound. The messages are also within several conversations.&lt;BR /&gt;&lt;BR /&gt;I am trying to create a new column that would indicate in the inbound message row the DateTime of the first outbound message if there was one. So, it must be filtered by Conversation_ID and if there's an outbound message after the inbound.&lt;BR /&gt;&lt;BR /&gt;I tried creating a duplicate table and filter that one where Outbound_Messages = 1, and then creating this new column in the Messages table like below. But the result sometimes works and sometimes it's empty.&lt;BR /&gt;&lt;BR /&gt;&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;AnsweredTime = 
    IF('Messages'[Inbound_Messages] = 1,
    CALCULATE (
	FIRSTNONBLANK ( 'Messages (Outbound)'[DateTime], True()),
	Filter(
		'Messages (Outbound)', 'Messages'[conversation_id] = 'Messages (Outbound)'[conversation_id] &amp;amp;&amp;amp;
		'Messages (Outbound)'[DateTime] &amp;gt;= 'Messages'[DateTime])) , BLANK())&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;The data looks something like this and the desired outcome is in the "Answered_Time" column.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;Please help to understand what I am doing wrong or if there's a better way to do it. If there's the possibility to have it all in one table (without having to create a table that is filtered by Outbound_messages = 1) then it would be even better.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;Thank you for your help!&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Aug 2022 15:24:00 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookup-first-date-if-available/m-p/2732976#M83738</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-08-29T15:24:00Z</dc:date>
    </item>
    <item>
      <title>Re: Lookup first date if available</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookup-first-date-if-available/m-p/2733262#M83763</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;why the result of the last row is bkank?&lt;/P&gt;</description>
      <pubDate>Mon, 29 Aug 2022 18:57:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookup-first-date-if-available/m-p/2733262#M83763</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-08-29T18:57:44Z</dc:date>
    </item>
    <item>
      <title>Re: Lookup first date if available</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookup-first-date-if-available/m-p/2733320#M83768</link>
      <description>&lt;P&gt;&amp;nbsp;Anonymous&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;based on the goven samle data and the the exoected result please try&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;AnsweredTime =
VAR CurrentDateTime = 'Messages (Outbound)'[DateTime]
VAR CurrentInbound = 'Messages (Outbound)'[Inbound_Messages]
VAR CurrentIDTable =
    CALCULATETABLE (
        'Messages (Outbound)',
        ALLEXCEPT ( 'Messages (Outbound)', 'Messages (Outbound)'[conversation_id] )
    )
VAR OutboundTable =
    FILTER ( CurrentIDTable, 'Messages (Outbound)'[Outbound_Messages] = 1 )
VAR OutboundDateTime =
    MINX ( OutboundTable, 'Messages (Outbound)'[DateTime] )
RETURN
    IF (
        CurrentInbound = 1
            &amp;amp;&amp;amp; CurrentDateTime &amp;lt; OutboundDateTime,
        OutboundDateTime
    )&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 29 Aug 2022 19:14:28 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookup-first-date-if-available/m-p/2733320#M83768</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-08-29T19:14:28Z</dc:date>
    </item>
    <item>
      <title>Re: Lookup first date if available</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookup-first-date-if-available/m-p/2733336#M83769</link>
      <description>&lt;LI-CODE lang="csharp"&gt;[First Outbound Time] = // calculated column, not a measure!
// In calculated columns one should in general never
// use CALCULATE. This is especially important in
// big fact tables and the reason being context transition
// that needs to happen on each and every row. You don't
// want that as it'll halt your calculation to a complete halt.
var CurrentConversationId = Messages[conversation_id]
var FirstOutboundTime =
    MINX(
        filter(
            Messages,
            Messages[Outbound_messages] = 1
            &amp;amp;&amp;amp;
            Messages[conversation_id] = CurrentConversationId
        ),
        Messages[DateTime]
    )
return
    FirstOutboundTime&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 29 Aug 2022 19:18:55 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookup-first-date-if-available/m-p/2733336#M83769</guid>
      <dc:creator>daXtreme</dc:creator>
      <dc:date>2022-08-29T19:18:55Z</dc:date>
    </item>
    <item>
      <title>Re: Lookup first date if available</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookup-first-date-if-available/m-p/2735404#M83880</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="349489" data-lia-user-login="daXtreme" class="lia-mention lia-mention-user"&gt;daXtreme&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Thank you for your help.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I believe this structure will always give the MIN date of the same conversation. However, let's say that the last row from the screenshot also gets answered, I want the AnsweredTime to have for that last row the DateTime of the new reply, not the previous.&lt;BR /&gt;&lt;BR /&gt;Hopefully it makes sense!&lt;/P&gt;</description>
      <pubDate>Tue, 30 Aug 2022 13:26:53 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookup-first-date-if-available/m-p/2735404#M83880</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-08-30T13:26:53Z</dc:date>
    </item>
    <item>
      <title>Re: Lookup first date if available</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookup-first-date-if-available/m-p/2735430#M83881</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="317289" data-lia-user-login="tamerj1" class="lia-mention lia-mention-user"&gt;tamerj1&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Thank you for your reply. With slight modification on the table names (instead of "Messages (Outbound)" it should be the table "Messages") looks like it's getting the result, but only for the first inbound message.&lt;BR /&gt;&lt;BR /&gt;Is there a way to apply the logic to all inbound messages? You asked as well why the last row is blank, and that's because there was no outbound message after the last inbound.&lt;BR /&gt;&lt;BR /&gt;But imagining that there is one, this would be the desired outcome:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Aug 2022 13:38:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookup-first-date-if-available/m-p/2735430#M83881</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-08-30T13:38:18Z</dc:date>
    </item>
    <item>
      <title>Re: Lookup first date if available</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookup-first-date-if-available/m-p/2735466#M83884</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="317289" data-lia-user-login="tamerj1" class="lia-mention lia-mention-user"&gt;tamerj1&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;By adding in the filter that also the DateTime is higher or equal to CurrentDateTime var I believe it's working.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;VAR OutboundTable =
    FILTER ( CurrentIDTable, 'Messages'[Outbound_Messages] = 1 &amp;amp;&amp;amp; 'Messages'[DateTime]&amp;gt;= CurrentDateTime)&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;&amp;nbsp;Thank you for your help!&lt;/P&gt;</description>
      <pubDate>Tue, 30 Aug 2022 13:49:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookup-first-date-if-available/m-p/2735466#M83884</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-08-30T13:49:32Z</dc:date>
    </item>
    <item>
      <title>Re: Lookup first date if available</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookup-first-date-if-available/m-p/2735467#M83885</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Please try&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;AnsweredTime =
VAR CurrentDateTime = 'Messages (Outbound)'[DateTime]
VAR CurrentInbound = 'Messages (Outbound)'[Inbound_Messages]
VAR CurrentIDTable =
    CALCULATETABLE (
        'Messages (Outbound)',
        ALLEXCEPT ( 'Messages (Outbound)', 'Messages (Outbound)'[conversation_id] )
    )
VAR OutboundTable =
    FILTER ( CurrentIDTable, 'Messages (Outbound)'[Outbound_Messages] = 1 )
VAR MinOutboundDateTime =
    MINX ( OutboundTable, 'Messages (Outbound)'[DateTime] )
VAR MaxOutboundDateTime =
    MAXX ( OutboundTable, 'Messages (Outbound)'[DateTime] )
RETURN
    IF (
        CurrentInbound = 1
            &amp;amp;&amp;amp; CurrentDateTime &amp;lt; MaxOutboundDateTime,
        MinOutboundDateTime
    )&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 30 Aug 2022 13:50:12 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Lookup-first-date-if-available/m-p/2735467#M83885</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-08-30T13:50:12Z</dc:date>
    </item>
  </channel>
</rss>

