Forum Discussion

ripstaur's avatar
ripstaur
Helper III
5 years ago
Solved

Calculating daily differences

I have a data set that contains columns for counties and states in the US, and COVID-19 case counts and deaths in each county each day. The numbers are cumulative...if there was one case on day one, ...
  • v-kelly-msft's avatar
    v-kelly-msft
    5 years ago

    Hi ripstaur ,

    First create an index column;

    Then create a column as below:

    Daily Cases =
    VAR _maxvalue =
        CALCULATE (
            MAX ( 'Table'[Cases] ),
            FILTER (
                'Table',
                'Table'[County] = EARLIER ( 'Table'[County] )
                    && 'Table'[Index] < EARLIER ( 'Table'[Index] )
            )
        )
    RETURN
        'Table'[Cases] - _maxvalue
    

    And you will see:

    For the related .pbix file,pls see attached.

     

    Best Regards,
    Kelly

    Did I answer your question? Mark my reply as a solution!