Running totals

Pettor

Board Regular
Joined
Aug 8, 2015
Messages
175
Hello guys,

Another question about running totals.

I run the below query where I want to calculate the running total up to a date where a specific condition is being met i.e. Action = X.
It works up to a point, but when it finds another value (see the list where value is "0") instead of bringing again the same number and continue from that number, it goes to the next one and has added also the 0 filed to the final total. I know it is the sum function but I can't think of a better way to do it.

Any opinion?

Thanks in advance

SQL:
SELECT DATE, PERSON, ACTION
(SELECT Sum(IIf(T1.ACTION="X",1,0)) FROM Results WHERE T1.MDATE >= MDate AND T1.PERSON = PERSON) AS ACTIONS
FROM DB AS T1
ORDER BY DATE, PERSON;
 

Attachments

  • tempsnip1.jpg
    tempsnip1.jpg
    28.8 KB · Views: 18
Last edited by a moderator:

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Hi guys, I just figured it out. I had to delete the T1. from the inside query! Sorry for the trouble! I hope it will work now!


SQL:
SELECT MDATE, PERSON, ACTION
(SELECT Sum(IIf([COLOR=rgb(184, 49, 47)]ACTION="X",1,0[/COLOR])) FROM Results WHERE T1.MDATE >= MDate AND T1.PERSON = PERSON) AS ACTIONS
FROM DB AS T1
ORDER BY MDATE, PERSON;
 
Last edited by a moderator:
Upvote 0
Solution

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,637
Latest member
Ezio2866

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top