<?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 What is the additional if statement that will return the first-non zero value from previous row? in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/What-is-the-additional-if-statement-that-will-return-the-first/m-p/2940435#M97090</link>
    <description>&lt;P&gt;&lt;SPAN&gt;I am currently doing a COVID-19 reports/dashboard through Power BI. I have this dax formula that will return the new cases for each day. However, the problem with this formula is that I am not able to return the value of the first case - it returns 0. May I ask for suggestion on how to make this formula return the value of first case as well?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Datasource:&amp;nbsp;&lt;A href="https://www.stackoverflow.com/" target="_blank" rel="noopener"&gt;https://github.com/CSSEGISandData/COVID-19/blob/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_confirmed_global.csv&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Source code:&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;New_Cases = 
VAR Countries = ConfirmedCases[Country/Region]
VAR State = ConfirmedCases[Province/State]
VAR dates = ConfirmedCases[Date]
VAR PrevDay =
CALCULATE(
    MAX(ConfirmedCases[Cases]),
    FILTER('ConfirmedCases',
    ConfirmedCases[Country/Region]=Countries &amp;amp;&amp;amp; ConfirmedCases[Province/State]=State &amp;amp;&amp;amp; ConfirmedCases[Date]&amp;lt;dates))
RETURN
IF(PrevDay=0,0,
IF(PrevDay&amp;gt;[Cases],0,
IF(PrevDay&amp;gt;0,[Cases]-PrevDay)))&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;Here is the current output:&amp;nbsp;&lt;img /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 01 Dec 2022 01:12:45 GMT</pubDate>
    <dc:creator>ironboy0418</dc:creator>
    <dc:date>2022-12-01T01:12:45Z</dc:date>
    <item>
      <title>What is the additional if statement that will return the first-non zero value from previous row?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/What-is-the-additional-if-statement-that-will-return-the-first/m-p/2940435#M97090</link>
      <description>&lt;P&gt;&lt;SPAN&gt;I am currently doing a COVID-19 reports/dashboard through Power BI. I have this dax formula that will return the new cases for each day. However, the problem with this formula is that I am not able to return the value of the first case - it returns 0. May I ask for suggestion on how to make this formula return the value of first case as well?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Datasource:&amp;nbsp;&lt;A href="https://www.stackoverflow.com/" target="_blank" rel="noopener"&gt;https://github.com/CSSEGISandData/COVID-19/blob/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_confirmed_global.csv&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Source code:&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;New_Cases = 
VAR Countries = ConfirmedCases[Country/Region]
VAR State = ConfirmedCases[Province/State]
VAR dates = ConfirmedCases[Date]
VAR PrevDay =
CALCULATE(
    MAX(ConfirmedCases[Cases]),
    FILTER('ConfirmedCases',
    ConfirmedCases[Country/Region]=Countries &amp;amp;&amp;amp; ConfirmedCases[Province/State]=State &amp;amp;&amp;amp; ConfirmedCases[Date]&amp;lt;dates))
RETURN
IF(PrevDay=0,0,
IF(PrevDay&amp;gt;[Cases],0,
IF(PrevDay&amp;gt;0,[Cases]-PrevDay)))&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;Here is the current output:&amp;nbsp;&lt;img /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Dec 2022 01:12:45 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/What-is-the-additional-if-statement-that-will-return-the-first/m-p/2940435#M97090</guid>
      <dc:creator>ironboy0418</dc:creator>
      <dc:date>2022-12-01T01:12:45Z</dc:date>
    </item>
    <item>
      <title>Re: What is the additional if statement that will return the first-non zero value from previous row?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/What-is-the-additional-if-statement-that-will-return-the-first/m-p/2940688#M97106</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="479972" data-lia-user-login="ironboy0418" class="lia-mention lia-mention-user"&gt;ironboy0418&lt;/a&gt; , Previous date when cases were 0 (New column) &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;New_Cases = &lt;BR /&gt;VAR Countries = ConfirmedCases[Country/Region]&lt;BR /&gt;VAR State = ConfirmedCases[Province/State]&lt;BR /&gt;VAR dates = ConfirmedCases[Date]&lt;BR /&gt;VAR PrevDay =&lt;BR /&gt;CALCULATE(&lt;BR /&gt;MAX(ConfirmedCases[dates]),&lt;BR /&gt;FILTER('ConfirmedCases',&lt;BR /&gt;ConfirmedCases[Country/Region]=Countries &amp;amp;&amp;amp; ConfirmedCases[Province/State]=State &amp;amp;&amp;amp; ConfirmedCases[Date]&amp;lt;dates &amp;amp;&amp;amp; ConfirmedCases[New_Cases]=0))&lt;BR /&gt;RETURN &lt;BR /&gt;PrevDay&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1st date when case were 0&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;New_Cases = &lt;BR /&gt;VAR Countries = ConfirmedCases[Country/Region]&lt;BR /&gt;VAR State = ConfirmedCases[Province/State]&lt;BR /&gt;VAR dates = ConfirmedCases[Date]&lt;BR /&gt;VAR PrevDay =&lt;BR /&gt;CALCULATE(&lt;BR /&gt;Min(ConfirmedCases[dates]),&lt;BR /&gt;FILTER('ConfirmedCases',&lt;BR /&gt;ConfirmedCases[Country/Region]=Countries &amp;amp;&amp;amp; ConfirmedCases[Province/State]=State &amp;amp;&amp;amp; ConfirmedCases[Date]&amp;lt;dates &amp;amp;&amp;amp; ConfirmedCases[New_Cases]=0))&lt;BR /&gt;RETURN &lt;BR /&gt;PrevDay&lt;/P&gt;</description>
      <pubDate>Thu, 01 Dec 2022 03:11:27 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/What-is-the-additional-if-statement-that-will-return-the-first/m-p/2940688#M97106</guid>
      <dc:creator>amitchandak</dc:creator>
      <dc:date>2022-12-01T03:11:27Z</dc:date>
    </item>
    <item>
      <title>Re: What is the additional if statement that will return the first-non zero value from previous row?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/What-is-the-additional-if-statement-that-will-return-the-first/m-p/2940819#M97116</link>
      <description>&lt;P&gt;Thanks amitchandak! Do I need to create two columns for these?&lt;/P&gt;</description>
      <pubDate>Thu, 01 Dec 2022 04:42:54 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/What-is-the-additional-if-statement-that-will-return-the-first/m-p/2940819#M97116</guid>
      <dc:creator>ironboy0418</dc:creator>
      <dc:date>2022-12-01T04:42:54Z</dc:date>
    </item>
    <item>
      <title>Re: What is the additional if statement that will return the first-non zero value from previous row?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/What-is-the-additional-if-statement-that-will-return-the-first/m-p/2941663#M97198</link>
      <description>&lt;P&gt;We got the answer! Sharing the appropriate solution:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;New_Cases = &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;VAR&lt;/SPAN&gt;&lt;SPAN&gt; Countries = Confirmed_Cases[Country/Region]&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;VAR&lt;/SPAN&gt;&lt;SPAN&gt; State = Confirmed_Cases[Province/State]&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;VAR&lt;/SPAN&gt;&lt;SPAN&gt; dates = Confirmed_Cases[Date]&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;VAR&lt;/SPAN&gt;&lt;SPAN&gt; tbl = &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;FILTER&lt;/SPAN&gt;&lt;SPAN&gt;('Confirmed_Cases',&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; Confirmed_Cases[Country/Region]=Countries &amp;amp;&amp;amp; Confirmed_Cases[Province/State]=State &amp;amp;&amp;amp; Confirmed_Cases[Date]&amp;lt;dates)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;VAR&lt;/SPAN&gt;&lt;SPAN&gt; PrevDay =&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;CALCULATE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;MAX&lt;/SPAN&gt;&lt;SPAN&gt;(Confirmed_Cases[Cases]),&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;tbl)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;RETURN&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;[Cases] - PrevDay&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 01 Dec 2022 10:23:07 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/What-is-the-additional-if-statement-that-will-return-the-first/m-p/2941663#M97198</guid>
      <dc:creator>ironboy0418</dc:creator>
      <dc:date>2022-12-01T10:23:07Z</dc:date>
    </item>
  </channel>
</rss>

