<?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 Forcing measure constant value after end_date in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Forcing-measure-constant-value-after-end-date/m-p/3703623#M144057</link>
    <description>&lt;P&gt;In my table, I have different components with start_date and end_date. There is a column with component_active_dates. Active dates are connected from Calendar table.&lt;/P&gt;&lt;P&gt;Also there is another table with mileage for different cars that are connected to components.&amp;nbsp;&lt;/P&gt;&lt;P&gt;My problem is because I slice mileage on component start and end date, when I plot component mileage it goes to 0 after end date.&amp;nbsp;&lt;BR /&gt;This mean that in the sum of mileage on all components there is a dip.&lt;/P&gt;&lt;P&gt;What I need is to push the last mileage on the end date, further till the end of Calendar.&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the code below, when I use&amp;nbsp;__convert it fills in for all Calendar dates, not just after the component_end, but if I put some number (for instance 500) then the whole thing is wokring and there is a flat line from compoenent_end till end of Calendar.&amp;nbsp;&lt;BR /&gt;I try to mimic simple number with casting measure as double but it didnt help.&amp;nbsp;&lt;BR /&gt;Any advice?&lt;/P&gt;&lt;P&gt;Thank you for your time&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="css"&gt;VAR __mileage_on_last_date =
    CALCULATE (
        MAX ( ft_aggregated[totalvehicledistancehighres_max] ),
        'Calendar'[Date] = __component_end) 
        
VAR __convert = CONVERT(__mileage_on_last_date, DOUBLE)
    
VAR __after_end_date =
    IF (
        TODAY() &amp;gt; __component_end,
        CALCULATE (
            __convert,
            FILTER (ALL ( 'Calendar' ), 'Calendar'[Date] &amp;gt;= __component_end)
        ),
        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;</description>
    <pubDate>Fri, 16 Feb 2024 09:49:16 GMT</pubDate>
    <dc:creator>niziris</dc:creator>
    <dc:date>2024-02-16T09:49:16Z</dc:date>
    <item>
      <title>Forcing measure constant value after end_date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Forcing-measure-constant-value-after-end-date/m-p/3703623#M144057</link>
      <description>&lt;P&gt;In my table, I have different components with start_date and end_date. There is a column with component_active_dates. Active dates are connected from Calendar table.&lt;/P&gt;&lt;P&gt;Also there is another table with mileage for different cars that are connected to components.&amp;nbsp;&lt;/P&gt;&lt;P&gt;My problem is because I slice mileage on component start and end date, when I plot component mileage it goes to 0 after end date.&amp;nbsp;&lt;BR /&gt;This mean that in the sum of mileage on all components there is a dip.&lt;/P&gt;&lt;P&gt;What I need is to push the last mileage on the end date, further till the end of Calendar.&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the code below, when I use&amp;nbsp;__convert it fills in for all Calendar dates, not just after the component_end, but if I put some number (for instance 500) then the whole thing is wokring and there is a flat line from compoenent_end till end of Calendar.&amp;nbsp;&lt;BR /&gt;I try to mimic simple number with casting measure as double but it didnt help.&amp;nbsp;&lt;BR /&gt;Any advice?&lt;/P&gt;&lt;P&gt;Thank you for your time&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="css"&gt;VAR __mileage_on_last_date =
    CALCULATE (
        MAX ( ft_aggregated[totalvehicledistancehighres_max] ),
        'Calendar'[Date] = __component_end) 
        
VAR __convert = CONVERT(__mileage_on_last_date, DOUBLE)
    
VAR __after_end_date =
    IF (
        TODAY() &amp;gt; __component_end,
        CALCULATE (
            __convert,
            FILTER (ALL ( 'Calendar' ), 'Calendar'[Date] &amp;gt;= __component_end)
        ),
        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;</description>
      <pubDate>Fri, 16 Feb 2024 09:49:16 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Forcing-measure-constant-value-after-end-date/m-p/3703623#M144057</guid>
      <dc:creator>niziris</dc:creator>
      <dc:date>2024-02-16T09:49:16Z</dc:date>
    </item>
    <item>
      <title>Re: Forcing measure constant value after end_date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Forcing-measure-constant-value-after-end-date/m-p/3703662#M144058</link>
      <description>&lt;P&gt;It seems like you're trying to handle the scenario where the mileage for a component remains constant after its end date until the end of the calendar period. You want to ensure that when you plot the mileage of components, it doesn't drop to zero after the end date but rather stays constant until the end of your calendar.&lt;/P&gt;&lt;P&gt;Your approach is mostly correct, but you're encountering issues with the calculation logic. Let's refine your DAX code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;VAR __mileage_on_last_date =&lt;BR /&gt;CALCULATE (&lt;BR /&gt;MAX ( ft_aggregated[totalvehicledistancehighres_max] ),&lt;BR /&gt;FILTER (ft_aggregated, ft_aggregated[component_active_dates] &amp;lt;= MAX('Calendar'[Date]))&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;VAR __after_end_date =&lt;BR /&gt;IF (&lt;BR /&gt;TODAY() &amp;gt; __component_end,&lt;BR /&gt;__mileage_on_last_date,&lt;BR /&gt;BLANK()&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;RETURN&lt;BR /&gt;__after_end_date&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's what each part of the DAX code does:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;P&gt;__mileage_on_last_date: This variable calculates the maximum mileage for the component until the last date available in the calendar. This is achieved by filtering the mileage data up to the maximum date available in the calendar.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;__after_end_date: This variable checks if the current date is greater than the component's end date. If it is, it returns the value of __mileage_on_last_date, effectively making the mileage constant after the end date. Otherwise, it returns BLANK().&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Finally, the RETURN statement returns the value of __after_end_date.&lt;/P&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Make sure that your ft_aggregated table is properly filtered to include only the relevant mileage data for the component you are analyzing. Adjust the filters and relationships according to your data model if needed.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;If this post&amp;nbsp;helps, then please consider&amp;nbsp;Accepting it as the solution&amp;nbsp;to help the other members find it more quickly.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;In case there is still a problem, please feel free and explain your issue in detail,&amp;nbsp;It will be my pleasure to assist you in any way I can.&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Feb 2024 10:10:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Forcing-measure-constant-value-after-end-date/m-p/3703662#M144058</guid>
      <dc:creator>123abc</dc:creator>
      <dc:date>2024-02-16T10:10:18Z</dc:date>
    </item>
    <item>
      <title>Re: Forcing measure constant value after end_date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Forcing-measure-constant-value-after-end-date/m-p/3750869#M146289</link>
      <description>&lt;P&gt;Thank you 123abc for your time and effort! The solution was very close to what you said and you were on track to take&amp;nbsp;&lt;SPAN&gt;MAX('Calendar'[Date])) as a limit.&amp;nbsp;&lt;BR /&gt;I will mark this as a Solution.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Sorry for the delay in my response.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Mar 2024 08:19:35 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Forcing-measure-constant-value-after-end-date/m-p/3750869#M146289</guid>
      <dc:creator>niziris</dc:creator>
      <dc:date>2024-03-08T08:19:35Z</dc:date>
    </item>
  </channel>
</rss>

