<?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: Need help with metric in direct query mode in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-with-metric-in-direct-query-mode/m-p/4588283#M175765</link>
    <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="275070" data-lia-user-login="VedranR" class="lia-mention lia-mention-user"&gt;VedranR&lt;/a&gt;&amp;nbsp;- If your DAX works in Import mode, then you should be asking the question why this needs to be Direct Query.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Performance will always be worse, and whilst end users say they need 'live' data, but are they really sat there watching your report refresh 24/7 - unlikely.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you would like someone to help, you'll need to supply your DAX.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 27 Feb 2025 15:40:06 GMT</pubDate>
    <dc:creator>mark_endicott</dc:creator>
    <dc:date>2025-02-27T15:40:06Z</dc:date>
    <item>
      <title>Need help with metric in direct query mode</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-with-metric-in-direct-query-mode/m-p/4587909#M175756</link>
      <description>&lt;P&gt;Hi everyone,&lt;BR /&gt;&lt;BR /&gt;I need help with some issue in PBI.&lt;BR /&gt;&lt;BR /&gt;In Power BI I have two tables 'Calendar' and 'report dealer_count_event_view'.&lt;BR /&gt;In the 'Calendar' table I have the data Date, while in the 'report dealer_count_event_view' table (which I import via direct query) we record all status changes (event_type) by users and I have separate data only for the date (event_date) and for the date and time together (event_time) for each record.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;It can happen that a user has multiple records on the same day, but with different times.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I need to create a report that will count only users whose last record in the observed month is deactivated (which does not have to be on the last day of the month), but that in the same month, on the day before that last record with the status (event_type) deactivated, there is a record with a status different from deactivated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a metric that works when the 'report dealer_count_event_view' table is not in direct query mode (ther is error fatching problem), but works when data is imported.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Is it possible to implement this in a single DAX metric in data query mode?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what the 'report dealer_count_event_view' dataset looks like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;user_id&lt;/TD&gt;&lt;TD&gt;event_time&lt;/TD&gt;&lt;TD&gt;event_date&lt;/TD&gt;&lt;TD&gt;event_type&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;823&lt;/TD&gt;&lt;TD&gt;25.12.2024 08:41&lt;/TD&gt;&lt;TD&gt;25.dec.24&lt;/TD&gt;&lt;TD&gt;deactivated&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;823&lt;/TD&gt;&lt;TD&gt;22.1.2025 16:11&lt;/TD&gt;&lt;TD&gt;22.jan.25&lt;/TD&gt;&lt;TD&gt;reactivated&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;823&lt;/TD&gt;&lt;TD&gt;23.1.2025 17:25&lt;/TD&gt;&lt;TD&gt;23.jan.25&lt;/TD&gt;&lt;TD&gt;deactivated&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;823&lt;/TD&gt;&lt;TD&gt;19.2.2025 15:51&lt;/TD&gt;&lt;TD&gt;19.feb.25&lt;/TD&gt;&lt;TD&gt;reactivated&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;17525&lt;/TD&gt;&lt;TD&gt;16.2.2025 16:35&lt;/TD&gt;&lt;TD&gt;16.feb.25&lt;/TD&gt;&lt;TD&gt;reactivated&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;19670&lt;/TD&gt;&lt;TD&gt;20.1.2025 19:21&lt;/TD&gt;&lt;TD&gt;20.jan.25&lt;/TD&gt;&lt;TD&gt;deactivated&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;192507&lt;/TD&gt;&lt;TD&gt;16.12.2024 13:20&lt;/TD&gt;&lt;TD&gt;16.dec.24&lt;/TD&gt;&lt;TD&gt;deactivated&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;192507&lt;/TD&gt;&lt;TD&gt;13.1.2025 15:11&lt;/TD&gt;&lt;TD&gt;13.jan.25&lt;/TD&gt;&lt;TD&gt;reactivated&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;192507&lt;/TD&gt;&lt;TD&gt;15.1.2025 15:12&lt;/TD&gt;&lt;TD&gt;15.jan.25&lt;/TD&gt;&lt;TD&gt;deactivated&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;535114&lt;/TD&gt;&lt;TD&gt;17.11.2024 09:12&lt;/TD&gt;&lt;TD&gt;17.nov.24&lt;/TD&gt;&lt;TD&gt;deactivated&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;535114&lt;/TD&gt;&lt;TD&gt;17.11.2024 08:36&lt;/TD&gt;&lt;TD&gt;17.nov.24&lt;/TD&gt;&lt;TD&gt;reactivated&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;535114&lt;/TD&gt;&lt;TD&gt;21.2.2025 19:33&lt;/TD&gt;&lt;TD&gt;21.feb.25&lt;/TD&gt;&lt;TD&gt;reactivated&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;535114&lt;/TD&gt;&lt;TD&gt;22.2.2025 19:25&lt;/TD&gt;&lt;TD&gt;22.feb.25&lt;/TD&gt;&lt;TD&gt;deactivated&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;676192&lt;/TD&gt;&lt;TD&gt;21.2.2025 15:41&lt;/TD&gt;&lt;TD&gt;21.feb.25&lt;/TD&gt;&lt;TD&gt;deactivated&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;676192&lt;/TD&gt;&lt;TD&gt;24.2.2025 11:25&lt;/TD&gt;&lt;TD&gt;24.feb.25&lt;/TD&gt;&lt;TD&gt;reactivated&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Thu, 27 Feb 2025 12:07:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-with-metric-in-direct-query-mode/m-p/4587909#M175756</guid>
      <dc:creator>VedranR</dc:creator>
      <dc:date>2025-02-27T12:07:30Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with metric in direct query mode</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-with-metric-in-direct-query-mode/m-p/4588283#M175765</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="275070" data-lia-user-login="VedranR" class="lia-mention lia-mention-user"&gt;VedranR&lt;/a&gt;&amp;nbsp;- If your DAX works in Import mode, then you should be asking the question why this needs to be Direct Query.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Performance will always be worse, and whilst end users say they need 'live' data, but are they really sat there watching your report refresh 24/7 - unlikely.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you would like someone to help, you'll need to supply your DAX.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Feb 2025 15:40:06 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-with-metric-in-direct-query-mode/m-p/4588283#M175765</guid>
      <dc:creator>mark_endicott</dc:creator>
      <dc:date>2025-02-27T15:40:06Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with metric in direct query mode</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-with-metric-in-direct-query-mode/m-p/4589172#M175794</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;Thanks for the solution &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="343036" data-lia-user-login="mark_endicott" class="lia-mention lia-mention-user"&gt;mark_endicott&lt;/a&gt;&amp;nbsp; offered, and i want to offer some more information for user to refer to.&lt;/P&gt;
&lt;P&gt;hello&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="275070" data-lia-user-login="VedranR" class="lia-mention lia-mention-user"&gt;VedranR&lt;/a&gt;&amp;nbsp;, you can refer to the following solution&lt;/P&gt;
&lt;P&gt;The sample data is the same as you provided, create the following measures.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;MEASURE =
VAR a =
    FILTER (
        ALLSELECTED ( 'report dealer_count_event_view' ),
        [user_id] IN VALUES ( 'report dealer_count_event_view'[user_id] )
    )
VAR b =
    MAXX ( a, [event_time] )
RETURN
    MAXX ( FILTER ( a, [event_time] = b ), [event_type] )
&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;Measure2 =
VAR a =
    FILTER (
        ALLSELECTED ( 'report dealer_count_event_view' ),
        [user_id] IN VALUES ( 'report dealer_count_event_view'[user_id] )
    )
VAR b =
    MAXX ( a, [event_time] )
RETURN
    MAXX (
        TOPN ( 1, FILTER ( a, [event_time] &amp;lt; b ), [event_time], DESC ),
        [event_type]
    )
&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;Measure3 =
CALCULATE (
    DISTINCTCOUNT ( 'report dealer_count_event_view'[user_id] ),
    FILTER (
        'report dealer_count_event_view',
        [Measure 2] &amp;lt;&amp;gt; "deactivated"
            &amp;amp;&amp;amp; [Measure] = "deactivated"
    )
)
&lt;/LI-CODE&gt;
&lt;P&gt;OUTPUT&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Best Regards!&lt;/P&gt;
&lt;P&gt;Yolo Zhu&lt;/P&gt;
&lt;P&gt;If this post&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;helps&lt;/EM&gt;&lt;/STRONG&gt;, then please consider&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Accept it as the solution&lt;/EM&gt;&lt;/STRONG&gt;&amp;nbsp;to help the other members find it more quickly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Feb 2025 02:45:57 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-with-metric-in-direct-query-mode/m-p/4589172#M175794</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2025-02-28T02:45:57Z</dc:date>
    </item>
  </channel>
</rss>

