How to add a rdlc group's totals row for an outer group's totals row - sum

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.

Related

Summing to columns into a third column in SSRS

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

how can I summarize different columns to make totals by row?

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))

Access VBA: Get difference in value between current and previous record

I have made report based on query according to this link:
http://www.techonthenet.com/access/queries/max_query2.php
It gives me list of records with values:
(primaryKey)
ID.......FirstNum....SecNum.....Diameter.....Owner
1........100200.......01...............150..............Peter
2........100200.......02...............138..............Peter
3........100300.......07...............112..............John
Query sorts records in descending order by Diametral. I want make new column which will count difference between first and second record, then between third and second and so on. Like this:
(primaryKey)
ID.......FirstNum....SecNum.....Diameter.....DiffDiametral.....Owner
1........100200.......01...............150.......................................Peter
2........100200.......02...............138.............12......................Peter
3........100300.......07...............112.............26.....................John
What should I write into RowSource or DataSource for DiffDiametral to get these values? How can I avoid error for first line, where is not previous value which I want substract from?
I tried to solve it according to this link:
http://support.microsoft.com/kb/101081/en-us
but I did not solve it. Simply I dont know how I can refer previous value of Diameter to count difference.
Based on your information, a subquery should do it. Just substitute your actual table name for tblDiameters.
SELECT C.ID, C.FirstNum, C.SecNum, C.Diameter, C.Owner,
(SELECT TOP 1 P.Diameter
FROM tblDiameters AS P
WHERE P.Diameter < C.Diameter
ORDER BY P.Diameter DESC )
- C.Diameter AS DiffDiameter
FROM tblDiameters AS C

Non blank cell count for a particular row in dynamic colums in ssrs with matrix

I have a SQL query like this
SELECT sam.AREATOPICID,
sec.SURVEYSECTION,
us.USERSURVEYID,
us.SURVEYAREATOPICID,
us.USERID,
usr.SURVEYUSERNAME,
us.COMMENT
FROM USERSURVEY us
INNER JOIN USERS usr
ON us.USERID = usr.USERID
INNER JOIN SURVEYAREATOPICMAPDEMO sam
ON sam.AREATOPICID = us.SURVEYAREATOPICID
INNER JOIN SECTION sec
ON sam.SURVEYSECTIONID = sec.SURVEYSECTIONID
ORDER BY us.USERID,
sam.AREATOPICID,
SURVEYSECTION
Now, in SSRS I want to display report like this
Now for comment, I want in a particular row how many users have comment on it. This field only have to show count of comments that are not blank and for a particular row(i.e. question).
I have done for user1, user2 .., type of column but I am not able to count the comment.
When you create your matrix, there are row (your question), column (your user) and a data cell (sum(COMMENT))in it. Right-click it and you should get Add Total menu item. Use it to add a column total. Then you can position that column to an appropriate location in your table.
EDIT
For counting records you use COUNT() like COUNT(Fields!Comment.Value)
For counting non-empty/null values use:
SUM(IIF(IsNothing(Fields!Comment.Value) OR (Fields!Comment.Value = ""),0,1))

SQL - How to insert a subquery into a query in order to retrieve unique values

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.