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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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.

Top Kudoed Authors