<?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: Dax function for calculation using Previous value in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dax-function-for-calculation-using-Previous-value/m-p/2637275#M77355</link>
    <description>&lt;P&gt;&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;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I downloaded your PBIX and can see that it's working.&lt;/P&gt;&lt;P&gt;However, there are a couple things I'm clearly not understanding.&lt;/P&gt;&lt;P&gt;Would you be able to educate me?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1) The final line of code is as follows: IF ( HASONEVALUE ( Data[Roll No] ), _countmeasure + _result )&lt;/P&gt;&lt;P&gt;- Why check to see if [Roll No] has a value?&amp;nbsp; (Isn't every row going to have a value?)&lt;/P&gt;&lt;P&gt;- Why not skip the IF check, and simply RETURN _countmeasure + _result?&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;P&gt;2) Per the requirements, only the first row uses [Count Measure] (value 10). The other rows don't use it at all.&amp;nbsp; Instead, they call the previous value (as you know).&lt;/P&gt;&lt;P&gt;- But to me, it appears that your code is treating all rows the same.&lt;/P&gt;&lt;P&gt;- For all 3 rows in your code, HASONEVALUE will return True.&lt;/P&gt;&lt;P&gt;- Therefore, for all 3 rows, the same calculation is returned:&amp;nbsp;_countmeasure + _result&lt;/P&gt;&lt;P&gt;- So how can the same calculation (which uses _countmeasure = 10) be used on all 3 rows, when _countmeasure should only be used on the first row?&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;P&gt;3) Finally, I'm not grasping how the FILTER function is calling the previous value.&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;P&gt;Data[Roll No] &amp;lt;= MAX ( Data[Roll No] )&amp;nbsp; &amp;nbsp;--GET ROWS WHERE [Roll No] &amp;lt;= MAX [Roll No]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- FILTER is an iterator, right?&lt;/P&gt;&lt;P&gt;- So it iterates through each row of the 'Data' table, performing the "&amp;lt;=" expression.&lt;/P&gt;&lt;P&gt;- For Row 1:&lt;BR /&gt;&amp;nbsp; &amp;nbsp;- Data[Roll No] = 6&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;- MAX(Data[RollNo]) = 8&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;- 6 &amp;lt;= 8 evaluates to True.&amp;nbsp; Therefore, this row is kept in the filter.&lt;/P&gt;&lt;P&gt;- For Row 2:&lt;BR /&gt;&amp;nbsp; &amp;nbsp;- Data[Roll No] = 7&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;- MAX(Data[RollNo]) = 8&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;- 6 &amp;lt;= 8 evaluates to True.&amp;nbsp; Therefore, this row is kept in the filter.&lt;/P&gt;&lt;P&gt;- For Row 3:&lt;BR /&gt;&amp;nbsp; &amp;nbsp;- Data[Roll No] = 8&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;- MAX(Data[RollNo]) = 8&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;- 8 &amp;lt;= 8 evaluates to True.&amp;nbsp; Therefore, this row is kept in the filter.&lt;/P&gt;&lt;P&gt;- As a result, all 3 rows are kept in the filter.&amp;nbsp;&lt;/P&gt;&lt;P&gt;- Am I reading the code correctly here?&lt;/P&gt;&lt;P&gt;- Regardless, for each row, &lt;EM&gt;how is the value from the previous row being used in the calculation?&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I really want to understand this.&amp;nbsp; Your help would be greatly appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Nathan&lt;/P&gt;</description>
    <pubDate>Wed, 13 Jul 2022 21:51:28 GMT</pubDate>
    <dc:creator>WinterMist</dc:creator>
    <dc:date>2022-07-13T21:51:28Z</dc:date>
    <item>
      <title>Dax function for calculation using Previous value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dax-function-for-calculation-using-Previous-value/m-p/2636712#M77314</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to achive the "Expected result" column in below table in one my Power Bi table, Kindly suggest is it possible to achive(Since I am new to Power Bi not sure about the correct function / logic to use here.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For the first Expected result "12" the "Count / 10" considered&amp;nbsp; is a Measure value from the same report.&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;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jul 2022 14:56:47 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dax-function-for-calculation-using-Previous-value/m-p/2636712#M77314</guid>
      <dc:creator>JayPee</dc:creator>
      <dc:date>2022-07-13T14:56:47Z</dc:date>
    </item>
    <item>
      <title>Re: Dax function for calculation using Previous value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dax-function-for-calculation-using-Previous-value/m-p/2636890#M77330</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;It is for creating a measure.&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;Expected result measure: = 
VAR _countmeasure = [Count measure:]
VAR _result =
    SUMX (
        FILTER ( ALL ( Data ), Data[Roll No] &amp;lt;= MAX ( Data[Roll No] ) ),
        Data[Basket A] + Data[Basket B] - Data[Basket C]
    )
RETURN
    IF ( HASONEVALUE ( Data[Roll No] ), _countmeasure + _result )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jul 2022 16:26:19 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dax-function-for-calculation-using-Previous-value/m-p/2636890#M77330</guid>
      <dc:creator>Jihwan_Kim</dc:creator>
      <dc:date>2022-07-13T16:26:19Z</dc:date>
    </item>
    <item>
      <title>Re: Dax function for calculation using Previous value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dax-function-for-calculation-using-Previous-value/m-p/2636975#M77336</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;&amp;nbsp;It worked in my report as well. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jul 2022 17:08:37 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dax-function-for-calculation-using-Previous-value/m-p/2636975#M77336</guid>
      <dc:creator>JayPee</dc:creator>
      <dc:date>2022-07-13T17:08:37Z</dc:date>
    </item>
    <item>
      <title>Re: Dax function for calculation using Previous value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dax-function-for-calculation-using-Previous-value/m-p/2637275#M77355</link>
      <description>&lt;P&gt;&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;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I downloaded your PBIX and can see that it's working.&lt;/P&gt;&lt;P&gt;However, there are a couple things I'm clearly not understanding.&lt;/P&gt;&lt;P&gt;Would you be able to educate me?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1) The final line of code is as follows: IF ( HASONEVALUE ( Data[Roll No] ), _countmeasure + _result )&lt;/P&gt;&lt;P&gt;- Why check to see if [Roll No] has a value?&amp;nbsp; (Isn't every row going to have a value?)&lt;/P&gt;&lt;P&gt;- Why not skip the IF check, and simply RETURN _countmeasure + _result?&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;P&gt;2) Per the requirements, only the first row uses [Count Measure] (value 10). The other rows don't use it at all.&amp;nbsp; Instead, they call the previous value (as you know).&lt;/P&gt;&lt;P&gt;- But to me, it appears that your code is treating all rows the same.&lt;/P&gt;&lt;P&gt;- For all 3 rows in your code, HASONEVALUE will return True.&lt;/P&gt;&lt;P&gt;- Therefore, for all 3 rows, the same calculation is returned:&amp;nbsp;_countmeasure + _result&lt;/P&gt;&lt;P&gt;- So how can the same calculation (which uses _countmeasure = 10) be used on all 3 rows, when _countmeasure should only be used on the first row?&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;P&gt;3) Finally, I'm not grasping how the FILTER function is calling the previous value.&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;P&gt;Data[Roll No] &amp;lt;= MAX ( Data[Roll No] )&amp;nbsp; &amp;nbsp;--GET ROWS WHERE [Roll No] &amp;lt;= MAX [Roll No]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- FILTER is an iterator, right?&lt;/P&gt;&lt;P&gt;- So it iterates through each row of the 'Data' table, performing the "&amp;lt;=" expression.&lt;/P&gt;&lt;P&gt;- For Row 1:&lt;BR /&gt;&amp;nbsp; &amp;nbsp;- Data[Roll No] = 6&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;- MAX(Data[RollNo]) = 8&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;- 6 &amp;lt;= 8 evaluates to True.&amp;nbsp; Therefore, this row is kept in the filter.&lt;/P&gt;&lt;P&gt;- For Row 2:&lt;BR /&gt;&amp;nbsp; &amp;nbsp;- Data[Roll No] = 7&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;- MAX(Data[RollNo]) = 8&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;- 6 &amp;lt;= 8 evaluates to True.&amp;nbsp; Therefore, this row is kept in the filter.&lt;/P&gt;&lt;P&gt;- For Row 3:&lt;BR /&gt;&amp;nbsp; &amp;nbsp;- Data[Roll No] = 8&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;- MAX(Data[RollNo]) = 8&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;- 8 &amp;lt;= 8 evaluates to True.&amp;nbsp; Therefore, this row is kept in the filter.&lt;/P&gt;&lt;P&gt;- As a result, all 3 rows are kept in the filter.&amp;nbsp;&lt;/P&gt;&lt;P&gt;- Am I reading the code correctly here?&lt;/P&gt;&lt;P&gt;- Regardless, for each row, &lt;EM&gt;how is the value from the previous row being used in the calculation?&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I really want to understand this.&amp;nbsp; Your help would be greatly appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Nathan&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jul 2022 21:51:28 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dax-function-for-calculation-using-Previous-value/m-p/2637275#M77355</guid>
      <dc:creator>WinterMist</dc:creator>
      <dc:date>2022-07-13T21:51:28Z</dc:date>
    </item>
    <item>
      <title>Re: Dax function for calculation using Previous value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dax-function-for-calculation-using-Previous-value/m-p/2637547#M77365</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;Thank you for your message.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. On each Roll No., a result is shown. But how do you want to show a result on TOTAL line? I did not know whether you want to show it as total (12+15+31) or something else, so I left it as blank by adding a condition with using hasonevalue dax function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. In my opinion, value 10 is used for all Roll No..&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Roll No.6 =&amp;nbsp;&lt;FONT color="#FF00FF"&gt;value 10 + 1 + 4 - 3&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;Roll No.7 =&lt;FONT color="#000000"&gt; RollNo6 + 9 + 2 - 8 &lt;/FONT&gt;= &lt;FONT color="#FF00FF"&gt;value 10 + 1 + 4 - 3&lt;/FONT&gt; + 9 + 2 - 8&lt;/P&gt;
&lt;P&gt;Roll No.8 = RollNo7 + 13 + 9 - 6 =&amp;nbsp;&lt;FONT color="#FF00FF"&gt;value 10 + 1 + 4 - 3&lt;/FONT&gt; + 9 + 2 - 8 + 13 + 9 - 6&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3. I corrected in red color in below.&lt;/P&gt;
&lt;P&gt;- For Row 1:&lt;BR /&gt;&amp;nbsp; &amp;nbsp;- Data[Roll No] = 6&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;- MAX(Data[RollNo]) = &lt;FONT color="#FF0000"&gt;6&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;- 6 &amp;lt;= &lt;FONT color="#FF0000"&gt;6&lt;/FONT&gt; evaluates to True.&amp;nbsp; Therefore, this row is kept in the filter.&lt;/P&gt;
&lt;P&gt;- For Row 2:&lt;BR /&gt;&amp;nbsp; &amp;nbsp;- Data[Roll No] = 7&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;- MAX(Data[RollNo]) = &lt;FONT color="#FF0000"&gt;7&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;- &lt;FONT color="#FF0000"&gt;6&amp;nbsp; and 7 &amp;lt;= 7&lt;/FONT&gt; evaluates to True.&amp;nbsp; Therefore, &lt;FONT color="#FF0000"&gt;this row including previous row&lt;/FONT&gt; are kept in the filter.&lt;/P&gt;
&lt;P&gt;- For Row 3:&lt;BR /&gt;&amp;nbsp; &amp;nbsp;- Data[Roll No] = 8&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;- MAX(Data[RollNo]) = 8&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;- &lt;FONT color="#FF0000"&gt;6, 7, and 8 &amp;lt;= 8&lt;/FONT&gt; evaluates to True.&amp;nbsp; Therefore,&lt;FONT color="#FF0000"&gt; this row including preivous rows&lt;/FONT&gt; are kept in the filter.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope it gives some idea.&lt;/P&gt;
&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jul 2022 03:04:48 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dax-function-for-calculation-using-Previous-value/m-p/2637547#M77365</guid>
      <dc:creator>Jihwan_Kim</dc:creator>
      <dc:date>2022-07-14T03:04:48Z</dc:date>
    </item>
    <item>
      <title>Re: Dax function for calculation using Previous value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dax-function-for-calculation-using-Previous-value/m-p/2638854#M77439</link>
      <description>&lt;P&gt;&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;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you &lt;EM&gt;very&lt;/EM&gt; much for the lesson.&lt;/P&gt;&lt;P&gt;This helps greatly!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Nathan&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jul 2022 13:18:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dax-function-for-calculation-using-Previous-value/m-p/2638854#M77439</guid>
      <dc:creator>WinterMist</dc:creator>
      <dc:date>2022-07-14T13:18:30Z</dc:date>
    </item>
  </channel>
</rss>

