<?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 Show increase or decrease from the previous row date/value (or second last), in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Show-increase-or-decrease-from-the-previous-row-date-value-or/m-p/1458510#M27478</link>
    <description>&lt;P&gt;Hi.&lt;BR /&gt;I have survey input where customers submit the most recent count of a required value.&amp;nbsp; I'm able to filter to the most recent submissions using MAX to get proper numbers, which is good.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I would like to show (in a report table) is the increase or decrease from the previous row date/value (or second last), if the value exisits (which it doesn't for some).&amp;nbsp; If no submission exisits I would like to show just the increase/decrease, and nothing for values that don't have a previous submission.&amp;nbsp; I've tried a bunch of measures but i'm not getting it.&lt;/P&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;To get the previous date value, I tried this combo of measures (which worked, but not sure if it's best):&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;SPAN&gt;&lt;STRONG&gt;measure1&lt;/STRONG&gt; = CALCULATE(MAX('data'[Start time]),&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;SPAN&gt;FILTER('data','data'[Start time] &amp;lt;&amp;gt;MAX('data'[Start time])&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;SPAN&gt;))&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;SPAN&gt;&lt;STRONG&gt;Last Submission Value&lt;/STRONG&gt; = &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;SPAN&gt;var secondlast = [measure1]&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;SPAN&gt;return&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;SPAN&gt;CALCULATE(SUM('data'[submittedValue]),'data'[Start time] = secondlast)&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;img /&gt;&lt;/DIV&gt;&lt;DIV&gt;However, when I subtract the second value from the &lt;STRONG&gt;most recent value&lt;/STRONG&gt;, the increase or decrease is correct for only the submissions that had a previous value.&amp;nbsp; The submissions that didn't have a value, the most recent value shows up and looks weird.&amp;nbsp; Same goes for calculating the percent change.&amp;nbsp; &amp;nbsp;100% shows up for those that didn't not have a previous value.&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;This is basically the format of the incoming background form data table.&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Location&lt;/TD&gt;&lt;TD&gt;SubmissionDate&lt;/TD&gt;&lt;TD&gt;Value&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Shelter A&lt;/TD&gt;&lt;TD&gt;October 23, 2020&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Shelter B&lt;/TD&gt;&lt;TD&gt;October 23, 2020&lt;/TD&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Shelter Z&lt;/TD&gt;&lt;TD&gt;October 24, 2020&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Shelter Z&lt;/TD&gt;&lt;TD&gt;October 22, 2020&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be great, but i'm ok if this is just not practical.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 27 Oct 2020 14:46:47 GMT</pubDate>
    <dc:creator>mcinnisbr</dc:creator>
    <dc:date>2020-10-27T14:46:47Z</dc:date>
    <item>
      <title>Show increase or decrease from the previous row date/value (or second last),</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Show-increase-or-decrease-from-the-previous-row-date-value-or/m-p/1458510#M27478</link>
      <description>&lt;P&gt;Hi.&lt;BR /&gt;I have survey input where customers submit the most recent count of a required value.&amp;nbsp; I'm able to filter to the most recent submissions using MAX to get proper numbers, which is good.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I would like to show (in a report table) is the increase or decrease from the previous row date/value (or second last), if the value exisits (which it doesn't for some).&amp;nbsp; If no submission exisits I would like to show just the increase/decrease, and nothing for values that don't have a previous submission.&amp;nbsp; I've tried a bunch of measures but i'm not getting it.&lt;/P&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;To get the previous date value, I tried this combo of measures (which worked, but not sure if it's best):&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;SPAN&gt;&lt;STRONG&gt;measure1&lt;/STRONG&gt; = CALCULATE(MAX('data'[Start time]),&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;SPAN&gt;FILTER('data','data'[Start time] &amp;lt;&amp;gt;MAX('data'[Start time])&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;SPAN&gt;))&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;SPAN&gt;&lt;STRONG&gt;Last Submission Value&lt;/STRONG&gt; = &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;SPAN&gt;var secondlast = [measure1]&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;SPAN&gt;return&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;SPAN&gt;CALCULATE(SUM('data'[submittedValue]),'data'[Start time] = secondlast)&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;img /&gt;&lt;/DIV&gt;&lt;DIV&gt;However, when I subtract the second value from the &lt;STRONG&gt;most recent value&lt;/STRONG&gt;, the increase or decrease is correct for only the submissions that had a previous value.&amp;nbsp; The submissions that didn't have a value, the most recent value shows up and looks weird.&amp;nbsp; Same goes for calculating the percent change.&amp;nbsp; &amp;nbsp;100% shows up for those that didn't not have a previous value.&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;This is basically the format of the incoming background form data table.&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Location&lt;/TD&gt;&lt;TD&gt;SubmissionDate&lt;/TD&gt;&lt;TD&gt;Value&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Shelter A&lt;/TD&gt;&lt;TD&gt;October 23, 2020&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Shelter B&lt;/TD&gt;&lt;TD&gt;October 23, 2020&lt;/TD&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Shelter Z&lt;/TD&gt;&lt;TD&gt;October 24, 2020&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Shelter Z&lt;/TD&gt;&lt;TD&gt;October 22, 2020&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be great, but i'm ok if this is just not practical.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Oct 2020 14:46:47 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Show-increase-or-decrease-from-the-previous-row-date-value-or/m-p/1458510#M27478</guid>
      <dc:creator>mcinnisbr</dc:creator>
      <dc:date>2020-10-27T14:46:47Z</dc:date>
    </item>
    <item>
      <title>Re: Show increase or decrease from the previous row date/value (or second last),</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Show-increase-or-decrease-from-the-previous-row-date-value-or/m-p/1458950#M27499</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="147658" data-lia-user-login="mcinnisbr" class="lia-mention lia-mention-user"&gt;mcinnisbr&lt;/a&gt;&amp;nbsp; Hi mcinnisbr, I might have misunderstood your question, if what you want is not to show any value for [Change from last report] and [diffMax2ndLast] in case there is no Last submission, I guess we can solve the problem by adding a condition such as&amp;nbsp; LastSubmissionValue &amp;gt;0 when we calculate these meaures.&lt;BR /&gt;e.g.) [diffMax2ndLast] = calculate( MostrecentSubmissionValue - LastSubmissionValue,&amp;nbsp;LastSubmissionValue &amp;lt;&amp;gt; blank()&amp;nbsp; )&lt;/P&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>Tue, 27 Oct 2020 18:13:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Show-increase-or-decrease-from-the-previous-row-date-value-or/m-p/1458950#M27499</guid>
      <dc:creator>colacan</dc:creator>
      <dc:date>2020-10-27T18:13:42Z</dc:date>
    </item>
    <item>
      <title>Re: Show increase or decrease from the previous row date/value (or second last),</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Show-increase-or-decrease-from-the-previous-row-date-value-or/m-p/1459090#M27501</link>
      <description>&lt;P&gt;Thanks for the reply.&amp;nbsp; That didnt quite work.&amp;nbsp; I'm probably not explaining things well either.&amp;nbsp; I guess what i'm trying to do is almost like a &lt;STRONG&gt;'change from last report'&lt;/STRONG&gt; like you see for COVID-19 case tables, but by customer instead of by date like you see in the covid screen below.&amp;nbsp;&amp;nbsp;&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;My raw table (forms submissions) looks like this.&amp;nbsp; I want to be able to subtract the last date from the previous and display the change in a report similar to my first post.&amp;nbsp; And, display + or - value by client, not by date.&amp;nbsp; &amp;nbsp;&lt;BR /&gt;&lt;STRONG&gt;Location SubmissionDate&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Value&amp;nbsp;&lt;/STRONG&gt; &amp;nbsp;&lt;BR /&gt;Shelter A&amp;nbsp; &amp;nbsp;October 23, 2020&amp;nbsp; &amp;nbsp; &lt;STRONG&gt;5&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/STRONG&gt;&lt;BR /&gt;Shelter B&amp;nbsp; &amp;nbsp;October 23, 2020&amp;nbsp; &amp;nbsp; &lt;STRONG&gt;6&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;&lt;BR /&gt;Shelter Z&amp;nbsp; &amp;nbsp;October 24, 2020&amp;nbsp; &amp;nbsp; &lt;STRONG&gt;3&lt;/STRONG&gt;&lt;BR /&gt;Shelter Z&amp;nbsp; &amp;nbsp;October 22, 2020&amp;nbsp; &amp;nbsp; &lt;STRONG&gt;4&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;If this is too confusing i'll have to try again another time.&amp;nbsp; &amp;nbsp;Thanks.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Oct 2020 19:40:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Show-increase-or-decrease-from-the-previous-row-date-value-or/m-p/1459090#M27501</guid>
      <dc:creator>mcinnisbr</dc:creator>
      <dc:date>2020-10-27T19:40:38Z</dc:date>
    </item>
    <item>
      <title>Re: Show increase or decrease from the previous row date/value (or second last),</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Show-increase-or-decrease-from-the-previous-row-date-value-or/m-p/1460455#M27533</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="147658" data-lia-user-login="mcinnisbr" class="lia-mention lia-mention-user"&gt;mcinnisbr&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think I understand what you mean.&lt;/P&gt;&lt;P&gt;The key to this is to position the second largest date for each location in the dataset.&lt;/P&gt;&lt;P&gt;Suppose we have the following data:&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;Then you need to create a calculated column (for example: [ID]) to mark the&amp;nbsp;second largest date:&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;ID = 
VAR _D =
    CALCULATE (
        MAX ( 'Sheet1'[SubmissionDate] ),
        ALLEXCEPT ( 'Sheet1', 'Sheet1'[Location] )
    )
VAR _LD =
    CALCULATE (
        MAX ( Sheet1[SubmissionDate] ),
        FILTER ( ALL ( Sheet1 ), 'Sheet1'[SubmissionDate] &amp;lt; _D )
    )
RETURN
    SWITCH ( 'Sheet1'[SubmissionDate], _D, 1, _LD, 2, BLANK () )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then you can create measures for both [MOST RECENT SUBMISSION] and [LAST SUBMISSSION], so that you can get the change for that:&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;CHANGE = 
VAR _THIS = [MOST RECENT]
VAR _LAST = [LAST]
RETURN
    DIVIDE ( _THIS - _LAST, _LAST, 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;SPAN&gt;The results are shown in the below figure, it works perfectly:&lt;/SPAN&gt;&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;&lt;STRONG&gt;&lt;EM&gt;Mark this post as solution if this helps,thanks!&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;( See&amp;nbsp;&lt;STRONG&gt;Davis.Z's blog&lt;/STRONG&gt;&amp;nbsp;at&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://www.linkedin.com/in/davis-zhang/detail/recent-activity/posts/" target="_self" rel="nofollow noopener noreferrer"&gt;&lt;STRONG&gt;LinkedIn&lt;/STRONG&gt;&lt;/A&gt;)&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Oct 2020 09:57:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Show-increase-or-decrease-from-the-previous-row-date-value-or/m-p/1460455#M27533</guid>
      <dc:creator>DavisBI</dc:creator>
      <dc:date>2020-10-28T09:57:50Z</dc:date>
    </item>
    <item>
      <title>Re: Show increase or decrease from the previous row date/value (or second last),</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Show-increase-or-decrease-from-the-previous-row-date-value-or/m-p/1472331#M27970</link>
      <description>&lt;P&gt;DavisBI,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many apologies, but i'm just getting to this.&amp;nbsp; This works very well and way more elegantly than my previous version for percentage.&amp;nbsp; &amp;nbsp;Is it possible to show the raw change value as 'blank' if there are no previous dates to subtract from?&amp;nbsp; My version works, but subtracting the the recent from the previous gives me the only value regardless.&amp;nbsp; if not possible, that's ok.&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.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Nov 2020 17:11:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Show-increase-or-decrease-from-the-previous-row-date-value-or/m-p/1472331#M27970</guid>
      <dc:creator>mcinnisbr</dc:creator>
      <dc:date>2020-11-03T17:11:31Z</dc:date>
    </item>
  </channel>
</rss>

