Forum Discussion

ironboy0418's avatar
ironboy0418
Helper II
3 years ago
Solved

What is the additional if statement that will return the first-non zero value from previous row?

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 t...
  • ironboy0418's avatar
    3 years ago

    We got the answer! Sharing the appropriate solution:

     

    New_Cases =
    VAR Countries = Confirmed_Cases[Country/Region]
    VAR State = Confirmed_Cases[Province/State]
    VAR dates = Confirmed_Cases[Date]
    VAR tbl =   FILTER('Confirmed_Cases',
        Confirmed_Cases[Country/Region]=Countries && Confirmed_Cases[Province/State]=State && Confirmed_Cases[Date]<dates)
    VAR PrevDay =
    CALCULATE(
        MAX(Confirmed_Cases[Cases]),
         tbl)
    RETURN
    [Cases] - PrevDay