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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Resolver III
Resolver III

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors