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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

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. 

 

Anteckning 2020-03-26 125205.png 

1 ACCEPTED SOLUTION
dax
Community Support
Community Support

Hi @Anonymous , 

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.

 

View solution in original post

3 REPLIES 3
tctrout
Responsive Resident
Responsive Resident

Hello @Anonymous 

 

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.

Anonymous
Not applicable

@tctrout Thank you! Ill give it a shot.

dax
Community Support
Community Support

Hi @Anonymous , 

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.

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors