So I have 4 columns of values in a table, Income, Expenditure, AIncome and AExpenditure.
I'm trying to get a running total in the final column Total. This the formula I have so far, which works:
=SUM(INDEX([Income],1):[#Income], INDEX([Expenditure],1):[#Expenditure], INDEX([AIncome],1):[#AIncome], INDEX([AExpenditure],1):[#AExpenditure])
My problem is that I don't know how to keep the sum in the Total column whenever I reload the table in Excel. The number of rows can vary from 1 to a few hundred.
Does anyone have any advice?
Thanks
An image of what the table looks like. THis is just a part with values in each column. J,K,L,M are Income, Expenditure, AIncome and AExpenditure. N is the total column. It's normally blank until I manually put in the formula.
Screenshot of part of the table
I can reload this table to get different values from the query I'm using, but that's not important. the problem is when I fetch the query again, there's a new table, always the same amount of columns, but not the same amount of rows. And then I need to manually put in my formula again in the total column
I would store the formula in a variable and after the query is loaded, copy the formula to the rows in the rnning total column.
Something like:
Const StoredFormula as string = "your formula"
Worksheets(x).range("range of the query table").formula = StoredFormula
Related
I have two columns in.column1, ou.column2. I would like to place a third column next to them that totals the number from both columns. I have tried an expression=sum(Fields!in.coulmn1.value,"new_dataset") +(Fields!in.coulmn2.value,"new_dataset")this does not give me the correct answer. Any help appreciated!
When trying the above expression I get a total that does not equal the total of the two columns.
Your code is summing all records in the dataset. If you just want totals per row, try removing the Sum call. Something like...
= Fields!in.column1.value + Fields!in.column2.value
The logic which we are trying to achieve in single query is as follows.
We need to loop based on row number column. So, on each loop we need to sum-up remaining value and new value.. resultant value to be updated in "by summing up column". and the decimal part to be updated in decimal value column.
in next step, need to sum-up the decimal value column by grouping on row number. and the resultant to be updated in remaining value column of next row number
the above step 1-2 to be continued till we reach last record.
We achieved this through while loop.. But trying to achieve this without while loop.
Can someone please give idea to achieve this
Please refer the attached image for understanding table
enter image description here
I am using the following query in SQL within PhpRunner:
SELECT
[Date],
(MondayStrengthEnd1Sets*MondayStrengthEnd1Reps*MondayStrengthEnd1Distance) + (MondayStrengthEnd2Sets*MondayStrengthEnd2Reps*MondayStrengthEnd2Distance) AS Total
FROM Running
When I run the query I get a blank for an answer. Some of the fields will not necessarily be filled in for every record. The example above is just a snippet of all the fields that is in the table and in the complete calculation, there will be almost 90 fields in total. All the fields are from the same table.
What can I add to the query to treat the blank fields as blanks and not as zeros in order to still calculate the total despite some fields not being filled in? If there is anything that will do it automatically for all the fields it would be great.
I am aiming for something like this:
It looks like you need something like:
SELECT
[Date],
isnull(MondayStrengthEnd1Sets*MondayStrengthEnd1Reps*MondayStrengthEnd1Distance, 0)
+ isnull(MondayStrengthEnd2Sets*MondayStrengthEnd2Reps*MondayStrengthEnd2Distance, 0)
AS Total
FROM Running
I'm using a Pivot Table in Excel 2010, and while searching posts I find that a lot of users are frustrated like me because it doesn't keep all formats.
So what I'm trying to do is run a macro that formats columns in a Pivot table, but limited to the last row and column in the table. I have the formatting info, but I just need to know how to apply it to specific columns and rows.
What I was thinking might work is finding the last column of the Values row, in this case "Stops per Rte" which is the last Values column; however, I have months listed at the top, so it repeats across months. If the user filters only certain months then the # of columns will decrease.
Same goes for the # of rows: of course, the user should be able to expand/collapse rows as needed, so I only want the column format to go to the last row or just above "Grand Total", if possible.
Hopefully, this makes sense. Thanks in advance! = )
How do I write a query in MS Access 2007 that displays both the count AND the percentage of the total records in a table for each row in a specified field?
For instance, if my table has a field called "gender," what is the query I should write to see the row count and percentage of Men and the row count and percentage of Women?
So, if the table had 1000 records, the result would look something like:
Men.....600.....60%
Women...400.....40%
I can easily write a query that just gives me the row count, but I can't figure out how to also see the percentages.
I should mention that I do not know SQL. I use the Design View when creating queries. But if you can give me the text for the query in SQL, I can copy and paste it into a new query and then save it.
It's not part of SQL itself, but you can use a VBA function in a query to count the amount of records in a table: DCount (MSDN).
Copy and paste the following lines in the query designer (top row, one line per column):
TotalMen: DCount("*";"[TableNameHere]";"[Gender]='Male'")
TotalWomen: DCount("*";"[TableNameHere]";"[Gender]='Female'")
You can then get the percentage by performing some simple math on the return values (again one line per column):
TotalPersons: [TotalMen]+[TotalWomen]
PercentageMen: [TotalMen]/[TotalPersons]
PercentageWomen: [TotalWomen]/[TotalPersons]
Don't forget to set the format to Percentage or the values will show up as 0,6 and 0,4 instead of 60% and 40%.
By the way, there are probably more consise ways to do it. I tried to make it readable.
PS: don't forget to replace the names of the tables and fields.