how can I summarize different columns to make totals by row?
on the picture below you can see my statement, definitely is something wrong there because is returning NULL value, but I don't know what it is. I want to create a TOTAL column summarizing WOSE, WO, SSSE and SS per row. Could someone help me with that?
It is because of null values in the columns -Use the following instead -
SUM(COALESCE(WOSE,0) +COALESCE(WO,0) + COALESCE(SSSE,0)+COALESCE(SS,0))
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
I have the following pivot table
I want to get the max value from each row, but also, I need to get the column it came from.
So far I know who to get the max row of every column using this:
dff['State'] = stateRace.max(axis=1)
dff
I get this:
which is returning the correct max value but not the column it came from.
You suffer a disadvantage getting help because you have supplied images and the question is not clear. Happy to help if the below answer doesn't help.
stateRace=stateRace.assign(max_value=stateRace.select_dtypes(exclude='object').max(axis=1),\
max_column=stateRace.select_dtypes(exclude='object').idxmax(axis=1))
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
I am writing reports using Report Builder 3, and I need some help with an sql query to get unique values.
Using the following sample data:
I need to be able to get one single value for feeBudRec returned for each feeRef. The value of each feeBudRec is always the same for each individual feeRef (eg for every data row for feeRef LR01 will have a feeBudRec of 1177).
The reason why I need to get a single feeBudRec value for each feeRef is that I need to be able to total the feeBudRec value for each feeRef in a feePin (eg for feePin LEE, I need to total the feeBudRec values for LR01 and PS01, which should be 1177 + 1957 to get a total of 3134; but if I don't have unique values for feeBudRec, it will add the values for each row, which would bring back a total of 11756 for the 8 LEE rows).
My experience with writing SQL queries is very limited, but from searching the internet, it looks like I'll need to put in a subquery into my SQL query in order to get a single unique feeBudRec figure for each feeRef, and that a subquery that gets a minimum feeBudRec value for each feeRef should work for me.
Based on examples I've found, I think the following subquery should work:
SELECT a.feeRef, a.feeBudRec
FROM (
SELECT uvw_EarnerInfo.feeRef, Min(uvw_EarnerInfo.feeBudRec) as AvailableTime
FROM uvw_EarnerInfo
GROUP BY
uvw_EarnerInfo.feeRef
) as x INNER JOIN uvw_EarnerInfo as a ON a.feeRef = x.feeRef AND a.feeBudRec = x.AvailableTime;
The problem is that I have no idea how to insert that subquery into the query I'm using to produce the report (as follows):
SELECT
uvw_EarnerInfo.feeRef
,uvw_EarnerInfo.PersonName
,uvw_EarnerInfo.PersonSurname
,uvw_EarnerInfo.feePin
,uvw_RB_TimeLedger.TimeDate
,uvw_RB_TimeLedger.matRef
,uvw_RB_TimeLedger.TimeTypeCode
,uvw_RB_TimeLedger.TimeCharge
,uvw_RB_TimeLedger.TimeElapsed
,uvw_WoffTimeByTime.WoffMins
,uvw_WoffTimeByTime.WoffCharge
,uvw_EarnerInfo.feeBudRec
,uvw_EarnerInfo.personOccupation
FROM
uvw_RB_TimeLedger
LEFT OUTER JOIN uvw_WoffTimeByTime
ON uvw_RB_TimeLedger.TimeId = uvw_WoffTimeByTime.TimeId
RIGHT OUTER JOIN uvw_EarnerInfo
ON uvw_EarnerInfo.feeRef = uvw_RB_TimeLedger.feeRef
WHERE
uvw_RB_TimeLedger.TimeDate >= #TimeDate
AND uvw_RB_TimeLedger.TimeDate <= #TimeDate2
If that subquery will get the correct results, can anyone please help me with inserting it into my report query. Otherwise, can anyone let me know what I will need to do to get a unique feeBudRec value for each feeRef?
Depends on the exact schema, but assuming the uvw_EarnerInfo lists the Pin, Ref, and Rec without duplicates, try adding an extra column (after personOccupation) on the end of your query such as :
feeBudRecSum = (Select SUM(FeeBudRec) From uvw_EarnerInfo x
where x.feePin = uvw_EarnerInfo.feePin
Group By x.FeePin)
Note that you would not Sum these values in your report. This column should have the total you are looking for.
The key to Report Builder is to get your query correct from the offset and let the wizard then structure your report for you. It takes all the hard work out of structuring your report manually.
I haven't used Report Builder for a while now but in the query builder of the report displaying the graphical representation of your query you should be able to drag and drop columns in and out of the query set. Dragging a column upwards and out of the box (showing your columns) would have the effect of causing your report to break on this column.
If you restructure this way you will probably have to run the report generator again to regenerate the report and restructure it.
Once you are happy with the structure you can then begin to add the summary columns.
I have a 2-level group report (rdlc). The inner group (GroupA) has in its totals row, totals of all record values, except one value which is the same for all records and for which that is the value I need to show(let's call that X). So the totals row looks like
Sum,Sum,....X
To do this I use Sum(Fields!,"GroupA") for all cells except this one, which is Fields!X.Value;
The outer group (Group B) must add all these values and display their sums in its totals row. The desired output should be:
Sum,Sum,.....Sum
So for all other fields, I use Sum(Fields!,"Group2").
What must I use for the X field? If I use Sum(Fields!X.Value,"Group2") it will add X as many numbers as there are records, where I want to add X for each group.
I really would appreciate a quick answer on this as I have to fix this problem yesterday :)
thanks
c.