Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
jovendeluna21
Helper IV
Helper IV

How to have new column/measure showing the difference of the data from previous dates

Hello,

Any idea on how to have new column showing the difference of the data from previous date. I just want to have daily distributed column since the total_distributed is cumulative.

For example, January 13, 2021 total_distributed will subtract to January 12 total_distributed (1,984,225 - 1,949,125 = 35,100), January 14, 2021 to January 13, 2021 (2,105,600 - 1,984,225 = 121,375) and so on. The challenge is location since it must harmonized to specific a location.

Attached herewith the pbi file.

https://drive.google.com/file/d/1jeGo2XIWc3oBwAkfWf4ScZISuXL4FKqo/view?usp=sharing

 

Thanks!

 

state.JPG

1 ACCEPTED SOLUTION
mahoneypat
Microsoft Employee
Microsoft Employee

Here is a measure expression that shows one way to do it.

 

Daily Distribution =
VAR vThisDate =
    MAX ( us_state_vaccinations[date] )
VAR vThisValue =
    SUM ( us_state_vaccinations[total_distributed] )
VAR vPrevValue =
    CALCULATE (
        LASTNONBLANKVALUE (
            us_state_vaccinations[date],
            CALCULATE (
                SUM ( us_state_vaccinations[total_distributed] )
            )
        ),
        ALL ( us_state_vaccinations[date] ),
        us_state_vaccinations[date] < vThisDate
    )
VAR vResult = vThisValue - vPrevValue
RETURN
    vResult

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

2 REPLIES 2
jovendeluna21
Helper IV
Helper IV

Is it possible to be a column instead of a measure?

mahoneypat
Microsoft Employee
Microsoft Employee

Here is a measure expression that shows one way to do it.

 

Daily Distribution =
VAR vThisDate =
    MAX ( us_state_vaccinations[date] )
VAR vThisValue =
    SUM ( us_state_vaccinations[total_distributed] )
VAR vPrevValue =
    CALCULATE (
        LASTNONBLANKVALUE (
            us_state_vaccinations[date],
            CALCULATE (
                SUM ( us_state_vaccinations[total_distributed] )
            )
        ),
        ALL ( us_state_vaccinations[date] ),
        us_state_vaccinations[date] < vThisDate
    )
VAR vResult = vThisValue - vPrevValue
RETURN
    vResult

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.