<?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: Changing the context  filter based inside a calculation in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Changing-the-context-filter-based-inside-a-calculation/m-p/3175466#M114614</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="148838" data-lia-user-login="amitchandak" class="lia-mention lia-mention-user"&gt;amitchandak&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for replying .I tried to do your code but doesn't work i this&amp;nbsp;&lt;SPAN&gt;[NB Client] = earlier([NB Client]) i have this error the parameter is not not the correct type .&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The&amp;nbsp;[NB Client] is measure with Distinctcount(client_id)&lt;BR /&gt;Any idea ?&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 06 Apr 2023 08:15:23 GMT</pubDate>
    <dc:creator>Mr_Robot0092</dc:creator>
    <dc:date>2023-04-06T08:15:23Z</dc:date>
    <item>
      <title>Changing the context  filter based inside a calculation</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Changing-the-context-filter-based-inside-a-calculation/m-p/3174812#M114573</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dimension that have the status of client(Active,inactive,...) , and i have a fact table that contains all my client with the status id and date key.&lt;/P&gt;&lt;P&gt;The status of client can change every day.&lt;/P&gt;&lt;P&gt;I have a report with a slicer on date and also some other filter in other dimension.&lt;/P&gt;&lt;P&gt;I have a table that show me the count of my client of each status .&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;NB Client	Status
17132		 ACTIVE
1530	     INACTIVE
152            N/A&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What i want is calculate the NB Client of each status and Adding and New status called Last Day Inactive&amp;nbsp; that show me the Nb Client that are inactive in my last Date of my filter.&lt;/P&gt;&lt;P&gt;Example :&amp;nbsp;&lt;/P&gt;&lt;P&gt;In my slicer i selected two Date from 1/04/2022 to&amp;nbsp;10/04/2022 .&lt;/P&gt;&lt;P&gt;The idea is calculate the NB Client in my Last Date in my case&amp;nbsp;10/04/2022 and showing the value , i want something like as bellow :&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;NB Client	Status
17132		 ACTIVE
1530	     INACTIVE
152            N/A
15	    Last Day INACTIVE&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What i did , i create Calculated table "&lt;STRONG&gt;DimStatusTR&lt;/STRONG&gt;" based on my Dimension table like this :&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;UNION (
    ROW (
        "Status_Key", "99",
        "Status_Label", "Last Day Inactive"
    ),
    SUMMARIZECOLUMNS (
        'DimStatus'[Status_Key],
        'DimStatus'[Status_Label]
    )
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I did a relationship between this new dimension and my Fact table , after that , i created a measure like as bellow :&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Var _InactiveLAstDay  = CALCULATE(
    [NbClient],
    FILTER(
        Fact_Client,
        RELATED('DimStatusTR'[Status_Label]) = "Inactive" &amp;amp;&amp;amp;
        Fact_Client[Date_Key] = MAX(Fact_Client[Date_Key])
    )
)


Var _OtherStatus = [NbClient]

Var _current = SELECTEDVALUE('DimStatusTR'[Status_Label])

Var result = if(_current ="Last Day Inactive",_InactiveLAstDay  +0,_OtherStatus)

Return result&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The result that i get is like as bellow :&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;NB Client	Status
17132		 ACTIVE
1530	     INACTIVE
152            N/A
0             Last Day INACTIVE&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What i want is something like that&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;NB Client	Status
17132		 ACTIVE
1530	     INACTIVE
152            N/A
15	    Last Day INACTIVE&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any idea how can i do that ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for help !&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Apr 2023 23:52:25 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Changing-the-context-filter-based-inside-a-calculation/m-p/3174812#M114573</guid>
      <dc:creator>Mr_Robot0092</dc:creator>
      <dc:date>2023-04-05T23:52:25Z</dc:date>
    </item>
    <item>
      <title>Re: Changing the context  filter based inside a calculation</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Changing-the-context-filter-based-inside-a-calculation/m-p/3174930#M114576</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="541387" data-lia-user-login="Mr_Robot0092" class="lia-mention lia-mention-user"&gt;Mr_Robot0092&lt;/a&gt; , First of all you need a date wise status for that. Now you can have column on meausre for what you need&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Like the last status column&amp;nbsp;&lt;/P&gt;
&lt;P&gt;=&lt;/P&gt;
&lt;P&gt;var _max = maxx(filter(Table, [NB Client] = earlier([NB Client])&amp;nbsp; &amp;amp;&amp;amp; [Date]&amp;nbsp; &amp;lt; Earlier([Date]) ) , [Date])&lt;/P&gt;
&lt;P&gt;return&lt;/P&gt;
&lt;P&gt;maxx(filter(Table, [NB Client] = earlier([NB Client])&amp;nbsp; &amp;amp;&amp;amp; [Date]&amp;nbsp; =_max ) , [Status])&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;for measure refer&lt;/P&gt;
&lt;P&gt;Power BI Abstract Thesis: How to use two Date/Period slicers&lt;/P&gt;
&lt;P&gt;&lt;A href="https://youtu.be/WSeZr_-MiTg" target="_blank"&gt;https://youtu.be/WSeZr_-MiTg&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Day Intelligence - Last day, l&lt;STRONG&gt;ast non continous day&lt;/STRONG&gt; &lt;BR /&gt;&lt;A href="https://medium.com/@amitchandak.1978/power-bi-day-intelligence-questions-time-intelligence-5-5-5c3243d1f9" target="_blank"&gt;https://medium.com/@amitchandak.1978/power-bi-day-intelligence-questions-time-intelligence-5-5-5c3243d1f9&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Apr 2023 01:46:40 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Changing-the-context-filter-based-inside-a-calculation/m-p/3174930#M114576</guid>
      <dc:creator>amitchandak</dc:creator>
      <dc:date>2023-04-06T01:46:40Z</dc:date>
    </item>
    <item>
      <title>Re: Changing the context  filter based inside a calculation</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Changing-the-context-filter-based-inside-a-calculation/m-p/3175466#M114614</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="148838" data-lia-user-login="amitchandak" class="lia-mention lia-mention-user"&gt;amitchandak&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for replying .I tried to do your code but doesn't work i this&amp;nbsp;&lt;SPAN&gt;[NB Client] = earlier([NB Client]) i have this error the parameter is not not the correct type .&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The&amp;nbsp;[NB Client] is measure with Distinctcount(client_id)&lt;BR /&gt;Any idea ?&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Apr 2023 08:15:23 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Changing-the-context-filter-based-inside-a-calculation/m-p/3175466#M114614</guid>
      <dc:creator>Mr_Robot0092</dc:creator>
      <dc:date>2023-04-06T08:15:23Z</dc:date>
    </item>
  </channel>
</rss>

