cancel
Showing results for
Did you mean:
Regular Visitor

## sum of two two cells with following dates with IF other cells equals XXX

Im trying to learn Power BI and using COVID-19 data as my data source. So I have data of COVID-19 cases per day and per country.

I want to create a new column that sums one date and the previous day for a specific country using Power Query. I have never created anything with Power Q before so keep in mind I am a real beginner.

Basically i want the formula to do this.

• Cell 1 =number of cases day 1
• Cell 2 = Sum of number of cases from day 1 and day 2
• Cell 3 = Sum of number of cases from day 2 and day 3
• etc
• It should also consider the name of Country in another cell so it doesnt sum the cases for two different countries.

I figure that i need to use IF and SUM functions for this but im having a hard time to figure out the code.

3 REPLIES 3
Highlighted
Helper II

## Re: sum of two two cells with following dates with IF other cells equals XXX

Hello @smileyours

If I understand you need correctly I think you are better off doing Rolling DAX caclulation as opposed to attempt to do this within M Code.

There are plenty of articles online regarding rolling sums in DAX, I think if you incorporate this with the What If Scenario features you will have the information you are seeking.

Regular Visitor

## Re: sum of two two cells with following dates with IF other cells equals XXX

@tctrout Thank you! Ill give it a shot.

Community Support

## Re: sum of two two cells with following dates with IF other cells equals XXX

Hi @smileyours ,

You could try to use measure like below to see whether it work or not.

Best Regards,
Zoe Zhi

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Announcements

#### New Ranks Launched March 24th!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power BI Community!

#### ‘Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

#### Arun 'Triple A' Event Video, Q&A, and Slides

Missed the Arun 'Triple A' event or want to revisit it? We've got you covered! Check out the video, Q&A, and slides now.

#### Community Summit North America

Innovate, Collaborate, Grow. The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors