<?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: Calculate Difference Between the last non blank value and the second last nonblank value with filter in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Difference-Between-the-last-non-blank-value-and-the/m-p/2535852#M71260</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;Please check the below picture and the attached pbix file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Mileage diff measure: =
VAR lastmileage =
    MAX ( Data[Mileage] )
VAR previousofthelastmileage =
    MAXX (
        FILTER (
            ALL ( Data ),
            Data[Reg no] = MAX ( Data[Reg no] )
                &amp;amp;&amp;amp; Data[Mileage] &amp;lt; lastmileage
        ),
        Data[Mileage]
    )
RETURN
    IF ( HASONEVALUE ( Data[Reg no] ), lastmileage - previousofthelastmileage )
&lt;/LI-CODE&gt;</description>
    <pubDate>Tue, 24 May 2022 10:13:00 GMT</pubDate>
    <dc:creator>Jihwan_Kim</dc:creator>
    <dc:date>2022-05-24T10:13:00Z</dc:date>
    <item>
      <title>Calculate Difference Between the last non blank value and the second last nonblank value with filter</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Difference-Between-the-last-non-blank-value-and-the/m-p/2535767#M71256</link>
      <description>&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Reg no&lt;/TD&gt;&lt;TD&gt;Mileage&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;CCN 342D&lt;/TD&gt;&lt;TD&gt;3342&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;CCN 455A&lt;/TD&gt;&lt;TD&gt;880&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;VWT 403B&lt;/TD&gt;&lt;TD&gt;10935&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;CCN 342D&lt;/TD&gt;&lt;TD&gt;4000&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;CCN 455A&lt;/TD&gt;&lt;TD&gt;1000&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;Please help with the dax function to calculate difference between the last non blank row and the second last non blank row.The reg number is repeated.&lt;/P&gt;</description>
      <pubDate>Tue, 24 May 2022 09:54:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Difference-Between-the-last-non-blank-value-and-the/m-p/2535767#M71256</guid>
      <dc:creator>Faith_Data</dc:creator>
      <dc:date>2022-05-24T09:54:32Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Difference Between the last non blank value and the second last nonblank value with filter</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Difference-Between-the-last-non-blank-value-and-the/m-p/2535847#M71259</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="393306" data-lia-user-login="Faith_Data" class="lia-mention lia-mention-user"&gt;Faith_Data&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Please provide the expected results as per the sample data provided.&lt;/P&gt;</description>
      <pubDate>Tue, 24 May 2022 10:11:48 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Difference-Between-the-last-non-blank-value-and-the/m-p/2535847#M71259</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-05-24T10:11:48Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Difference Between the last non blank value and the second last nonblank value with filter</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Difference-Between-the-last-non-blank-value-and-the/m-p/2535852#M71260</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;Please check the below picture and the attached pbix file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Mileage diff measure: =
VAR lastmileage =
    MAX ( Data[Mileage] )
VAR previousofthelastmileage =
    MAXX (
        FILTER (
            ALL ( Data ),
            Data[Reg no] = MAX ( Data[Reg no] )
                &amp;amp;&amp;amp; Data[Mileage] &amp;lt; lastmileage
        ),
        Data[Mileage]
    )
RETURN
    IF ( HASONEVALUE ( Data[Reg no] ), lastmileage - previousofthelastmileage )
&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 24 May 2022 10:13:00 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Difference-Between-the-last-non-blank-value-and-the/m-p/2535852#M71260</guid>
      <dc:creator>Jihwan_Kim</dc:creator>
      <dc:date>2022-05-24T10:13:00Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Difference Between the last non blank value and the second last nonblank value with filter</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Difference-Between-the-last-non-blank-value-and-the/m-p/2536193#M71276</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="291628" data-lia-user-login="Jihwan_Kim" class="lia-mention lia-mention-user"&gt;Jihwan_Kim&lt;/a&gt; for faster response ,however the measure on my end is bringing all blanks&lt;/P&gt;</description>
      <pubDate>Tue, 24 May 2022 12:32:15 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Difference-Between-the-last-non-blank-value-and-the/m-p/2536193#M71276</guid>
      <dc:creator>Faith_Data</dc:creator>
      <dc:date>2022-05-24T12:32:15Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Difference Between the last non blank value and the second last nonblank value with filter</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Difference-Between-the-last-non-blank-value-and-the/m-p/2536257#M71281</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;Please share your sample pbix file's link, and then I can try to look into it to come up with a more accurate solution.&lt;/P&gt;
&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 24 May 2022 12:49:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Difference-Between-the-last-non-blank-value-and-the/m-p/2536257#M71281</guid>
      <dc:creator>Jihwan_Kim</dc:creator>
      <dc:date>2022-05-24T12:49:32Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Difference Between the last non blank value and the second last nonblank value with filter</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Difference-Between-the-last-non-blank-value-and-the/m-p/2536561#M71300</link>
      <description>&lt;P&gt;&lt;A href="https://vael-my.sharepoint.com/:u:/g/personal/database_vaell_com/EdXsZc6hXu9LtiR9R9CF5BgBYm3o2LlxlXFwZzSeF8HekQ?e=WT8das" target="_blank"&gt;Faith_Data v1.pbix&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 24 May 2022 14:13:57 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Difference-Between-the-last-non-blank-value-and-the/m-p/2536561#M71300</guid>
      <dc:creator>Faith_Data</dc:creator>
      <dc:date>2022-05-24T14:13:57Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Difference Between the last non blank value and the second last nonblank value with filter</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Difference-Between-the-last-non-blank-value-and-the/m-p/2538133#M71405</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="393306" data-lia-user-login="Faith_Data" class="lia-mention lia-mention-user"&gt;Faith_Data&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Here you go&amp;nbsp;&lt;A href="https://we.tl/t-Mrey2dTPxa" target="_blank"&gt;https://we.tl/t-Mrey2dTPxa&lt;/A&gt;&lt;/P&gt;&lt;P&gt;First of all make sure the have the mileage column as intiger data type.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;Mileage diff measure - Tamer = 
SUMX ( 
    VALUES ( 'PM Data'[REG NO] ),
    CALCULATE (
        VAR LastTwoDatesTable = TOPN ( 2,'PM Data', 'PM Data'[LAST SERVICE], DESC )
        VAR Last_Date = MAXX ( LastTwoDatesTable, 'PM Data'[LAST SERVICE] )
        VAR Last_2ndDate = MINX ( LastTwoDatesTable, 'PM Data'[LAST SERVICE] )
        VAR Last_DateMileage = MAXX ( FILTER ( LastTwoDatesTable, 'PM Data'[LAST SERVICE] = Last_Date ), 'PM Data'[LAST MILEAGE] )
        VAR Last_2ndDateMileage = MAXX ( FILTER ( LastTwoDatesTable, 'PM Data'[LAST SERVICE] = Last_2ndDate ), 'PM Data'[LAST MILEAGE] )
        RETURN
            IF ( 
                COUNTROWS ( LastTwoDatesTable ) &amp;gt;= 2,
                Last_DateMileage - Last_2ndDateMileage
            )
    )
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 25 May 2022 07:52:46 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Difference-Between-the-last-non-blank-value-and-the/m-p/2538133#M71405</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-05-25T07:52:46Z</dc:date>
    </item>
  </channel>
</rss>

