I am trying to achieve something as above. Basically, the Months subtotals are represented by A and B. Then (X-A) and (X-A-B) are also the subtotals at the same group level as A and B but don't simply display the total for respective years 2007 and 2008, instead those are remaning totals from X. In order to calculate the remaining totals however, one need to consider the subtotal in previous group. For example, for 2007 its X-A, but for 2008 its X-A-B. I would like to know if this can be achieved using Matrix control. If so, what would be the steps?
The problem that i'm having right now is on the layout designer somehow programming the subtotals based on the IDs. Am i thinking in the right direction that I should be using the layout designer to do this? Or should this be done programmatically?
I have the matrix above that displays the subtotals per customer(group_row), per quarter(group_column). I added a subtotal to the top group_column (year) so I can get grand total. I need to modify grand total formula to display variance instead.
I don't need to modify the subtotal formula per Customer/quarter , only per cutomer/Year. Is it possible?
I have contracts grouped by project then grouped by division. On the division group header I want to show the subtotal of all active projects only. CountDistinct(Fields!ProjectId.Value) gives me count of all projects.
I can't figure out what I need to get only a subset of projects counted. I need something like:
SELECT LTRIM(LoanAnalyst) AS [Loan Analyst] ,DischargeType AS [Discharge Type] ,CONVERT(varchar, DateCompleted, 101) AS [Date Completed] ,COUNT(ClaimID) As [Completions]
[Code] ....
This produces this
Loan AnalystDischarge TypeDate CompletedCompletions Bill ReidType 1 3/3/20151 Bill ReidType 1 2/11/20151 Bill ReidType 2 3/11/201518 Bill ReidType 3 3/11/20151 Bill ReidType 4 3/11/20159
[Code] ....
I would like my results to look like this. I've tried using WITH ROLLUP but it doesn't give me the below.
Loan AnalystDischarge TypeDate CompletedCompletions Bill ReidType 1 3/3/20151 Bill ReidType 1 2/11/20151 Bill ReidType 2 3/11/201518 Bill ReidType 3 3/11/20151 Bill ReidType 4 3/11/20159 30
How can I calculate a subtotal for a Report Item? I have a textbox(lets call it "PlusMinus") in the detail section of my table, which is a calculated textbox of two others (lets call them "Budget" and "Spent"). So, PlusMinus = (Budget - Spent). What I would like to do is get a subtotal for PlusMinus. I have tried several ways, using Sum() or RunningValue, even tried to write code, but I can't seem to get it right. Any ideas??
i have the following problem: I have a matrix with a right subtotal column and this matrix was in a list (because in the end i will have more than one matrix). The list fits perfectly the matrix in design mode. But if i render the report in the viewer or to pdf, an additional blank area (like a blank copy of the subtotal column) was inserted after the right subtotal column of the matrix and increases the list too. You can see this easy by set the backgroundcolor of a list to a color. Without the subtotal column the list fits perfect after rendering. The problem is that this additional blank "column" creates empty pages in .pdf rendering, if the width of the matrix is near the page width. The same behaviour happens if i put the matrix with subtotal in a rectangle. I must use a list in the end because the the final report contains some matrixes and a subreport. So is this a bug? Someone must have this problem too?
I would like to be able to add subtotals for extended_cost and tax_amt for the following query and then a net_cost that is a sum of extended_Cost and tax_amt for each of the orders I have. I believe I need to somehow use the Group by command, but with so many fields from so many fields, I am not sure where to start. Here is my code so far...
Code:
SELECT Customer.First_Name, Customer.Middle_Name, Customer.Last_Name, Customer.Address, Customer.City, Customer.Region, Customer.Postal_Code, Customer.Country, Customer.Customer_ID, Store.Store_Address, Store.Store_City, Store.Store_State, Store.Store_Zip_code, Store.Store_Phone_Number, Store.Store_Fax_Number, Orders.Order_ID, Employees.LastName, Employees.FirstName, Item.Item_ID, Item.Taxable_Nontaxable, Order_Line.Price, Order_Line.Units_Purchased, Order_Line.Discount, Tax_Table.Tax_Rate, 'Extended_Price' = (Order_Line.Price*Order_Line.Units_Purchased*(1-Order_Line.Discount)), CASE WHEN Item.Taxable_Nontaxable = 1 THEN ((Order_Line.Price*Order_Line.Units_Purchased*(1-Order_Line.Discount))*Tax_Table.Tax_Rate) ELSE ((Order_Line.Price*Order_Line.Units_Purchased*(1-Order_Line.Discount))*0) END AS Tax_Amt FROM Orders INNER JOIN Order_Line ON Orders.Order_ID = Order_Line.Order_ID INNER JOIN Customer ON Orders.Customer_ID = Customer.Customer_ID INNER JOIN Store ON Orders.Store_Code = Store.Store_Code INNER JOIN Employees ON Orders.Sales_Person_ID = Employees.EmployeeID INNER JOIN Item ON Order_Line.Item_ID = Item.Item_ID INNER JOIN Tax_Table ON Orders.Store_Code = Tax_Table.Store_Code WHERE Orders.Order_Filled = 0 ORDER BY Orders.Order_ID COMPUTE SUM((Order_Line.Price*Order_Line.Units_Purchased*(1-Order_Line.Discount))) BY Orders.Order_ID
I have a dimension that has the following members:
Directors
Senior Managers
Managers
Senior Associates
Associates
But they way they need to be displayed includes subtotals. Senior Managers and Managers are placed into Management and Staff is a total of everyone except Directors. They should appear on the report in something like this:
Directors 10
Senior Managers 15
Managers 9
Management 24
Senior Associates 17
Associates 40
Staff 81
Total 91
What is the best way to do this? Right now I am using a matrix because I am also showing headcounts by Period. Is a table a better way to go? Is it something that should be done in my dimension?
I can do the Total part. I am just not sure how to make the subtotals inbetween the other lines.
2003 2004 2005 Total cars apples cars apples cars apples Tom 3 1 4 2 5 1 16 Sally 0 2 4 1 7 6 20
And I need the last column (the group subtotals) to be like this:
Totals cars apples 12 4 11 9
So basically, the question is, how do I get the second column-group (cars/apples) subtotals to appear in the last column? As seen, the the subtotal for the first column-group (year) is meaningless.
I have a matrix report which is showing user information. The Rows are displaying numbers for each user, and the columns show the user info in weekly increments. I have 7 fields of info for each user. My stored procedure already is set up to give me the correct numbers. I dont need to SUM them or anything. Although in the report designer it forced me to SUM them since it was part of an aggregate. This still worked for me anyhow because it was Summing a single value.
However, at the end of the report i want to display totals for all the users combined, per week. So right now the report is showing 21 weeks, so at the end of the report i should have 21 sets of totals.
I right clicked on the users name column and selected subtotal. This gave me some of what i want. But some of the numbers are not correct. Some of the numbers should not just be a simple SUM of the column. Some of the values should be averages etc. I know how to calculate those values myself (its very simple math) but i dont know how to do it using this setup in the report designer. So in the matrix, for each week, how can i calculate the totals for all the users combined and specify the formula used to get the totals for each field?
I am new to SQL and have been given the task of adding Subtotals and a Grand Total to a report. Below is my code...can someone point me in the right direction?
SELECT POP30300.POPRCTNM, receiptdate, VENDORID, VENDNAME, POP30310.ITEMNMBR, SERLTNUM LOTNUMBR, LandedCost = ISNULL(CONVERT(money,LOTATRB1),0), STNDCOST = ISNULL(CONVERT(money,STNDCOST),0), LandedCostStatus = CASE WHEN CONVERT(money,ISNULL(LOTATRB1,0)) = 0 THEN 'Missing' ELSE CASE WHEN (CONVERT(money,ISNULL(LOTATRB1,0))-STNDCOST)/STNDCOST*100 NOT BETWEEN -30 AND 30 THEN 'OutOfRange' ELSE 'Okay' END END, PONUMBER, ISNULL(POP30310.UNITCOST,0) / ISNULL(POP30310.UMQTYINB,1) POPRICE, ISNULL(QTYAVAIL,0) QTYAVAIL FROM ODB.dbo.POP30300 POP30300 (NOLOCK) INNER JOIN ODB.dbo.POP30310 POP30310 (NOLOCK) ON POP30300.POPRCTNM = POP30310.POPRCTNM INNER JOIN ODB.dbo.POP30330 POP30330 (NOLOCK) ON POP30310.POPRCTNM = POP30330.POPRCTNM AND POP30310.RCPTLNNM = POP30330.RCPTLNNM INNER JOIN ODB.dbo.IV00301 IV00301 (NOLOCK) ON POP30330.ITEMNMBR = IV00301.ITEMNMBR AND POP30330.SERLTNUM = IV00301.LOTNUMBR LEFT JOIN ODB.dbo.IV00101 IV00101 (NOLOCK) on POP30330.ITEMNMBR = IV00101.ITEMNMBR LEFT JOIN (SELECT ITEMNMBR, LOTNUMBR, SUM(QTYRECVD-QTYSOLD-ATYALLOC) QTYAVAIL FROM ODB.dbo.IV00300 IV00300 (NOLOCK) GROUP BY ITEMNMBR, LOTNUMBR) QTYAVAIL ON POP30330.ITEMNMBR = QTYAVAIL.ITEMNMBR AND POP30330.SERLTNUM = QTYAVAIL.LOTNUMBR WHERE POP30300.POPTYPE IN (1,3) AND POP30300.VOIDSTTS = 0 -- AND POP30300.receiptdate > DATEADD(dd,-35,GETDATE()) AND ISNUMERIC(LOTATRB1) = 1 AND ISNULL(QTYAVAIL,0) <> 0
I want to display subtotals for a column only for that page. Like;
Index Value ----------------------------- 1 4 2 5 Subtotal 9 ---------------------------- 3 1 4 2 Subtotal 3 Total 12
RunningValue gives cumulative totals. I need subtotals for each visible page only. Is there a way to do it ? Constraints: I'm using a table. And I shouldn't use page breaks on my report.
For the past two hours I've been looking for a solution to my problem. Any help is appreciated. Basically, I need to know the T-SQL Command(s) that create subtotals and grandtotals within a set of results. I am designing a school transcript generator and I need to calculate the GPA and Credit Hour Totals per Semester, For Example:
Semester 1 Record Semester 1 Record Semester 1 Record Semester 1 Record Semester 1 Record Semester 1 Subtotal Semester 2 Record Semester 2 Record Semester 2 Record Semester 2 Record Semester 2 Record Semester 2 Subtotal Semester 3 Record Semester 3 Record Semester 3 Record Semester 3 Record Semester 3 Record Semester 3 Subtotal Year 1 Grand Total
Hi I have a matrix report. It expands to the right when the user chooses the amounts of months he/she wishes to see. Then it is populated with revenues for each month and deportment. On the matrix report I have put in a couple of Subtotals. Some of the totals are empty due to a month in a department with no revenue.
I wish to see a 0 on the subtotal column but I don€™t want to see a 0 on the month column. If I use =IIF( Fields!Revenue.Value is Nothing, "0", Fields!Revenue.Value) on the month columns I will see 0 all over the place. But I only want a 0 on the subtotal column. Can I do this?
I am having some trouble with this very complicated stored procedure. It is for a transcript generator. The following code does work as it is. The stored procedure return all rows from the ClassGrades table, with subtotals for each semester and a grand total. The two things that I need to add to this stored procedure is:
The ability to query only the records, subtotal, and total for the studentID in the variable @StudentID. I have tried adding WHERE statements where they are usually found, but ends up return no rows as a result. Should I be using the HAVING statement?
The calculation of cumulative GPA, where each semester before affects all semester at a later date. If this is impossible, which to my knowledge is, its not required. Its just a nice thing to have.
Here is the current code:
ALTER PROCEDURE [dbo].[ClassGrades_FillStudent]
@StudentID text
AS
BEGIN
SELECT StudentID, SemesterCode,ClassID, Grade, CreditHours, QualityPoints FROM (
SELECT 0 AS sort1, StudentID, SemesterCode, dbo.DropDownItems_GetValue(ClassID) AS ClassID, Grade, CreditHours, Grade*CreditHours AS QualityPoints
, 0 AS sort2 FROM ClassGrades
UNION ALL
SELECT 0,Null, SemesterCode + 'TOTAL',Null,(SUM(Grade*CreditHours)/SUM(CreditHours)), SUM(CreditHours), SUM(Grade*CreditHours) AS QualityPoints , 1 FROM ClassGrades
GROUP BY SemesterCode + 'TOTAL'
UNION ALL
SELECT 1, Null, 'Grand Total',Null, (SUM(Grade*CreditHours)/SUM(CreditHours)), SUM(CreditHours), SUM(Grade*CreditHours) AS QualityPoints, 1 FROM ClassGrades
I am trying to dynamically create subtotals base on values in a column. I also have to group by year. I have gotten the group by year. I used the (previous function) to check for the year and col1 not being equal. I am getting the first subtotal back, don't know how to proceed in my function to return the remaining subtotals
I'm wondering if its possible to use the subtotal for one group in a matrix in an expression for another group in the matrix.
Im getting the total number of units someone holds in one column, and need to show the percentage of the total units in another column.
An example of what im doing is below... argh images dont seem to be working when you post then! sorry
the first group is Date - This will show all there quantities anytime a trade occurs.
the second and third groups are Quantity (of units) and % of fund.
Quantity is a running value of all the units the account holder has. The percentage needs to be that number / subtotal of all units on that date. So the expression needs to be something like:
=runningvalue(Fields!Quantity.Value, sum, "matrix1_Account_Reference") / --subtotal of date group-- * 100
Let's say I have raw data that looks something like this
Fruit_name status count apples Fresh 5 apples rotten 3 pears Fresh 3 pears rotten 2
and I was to matrix it and group on fruit_name and add a subtotal to count. In that subtotal, without changing what was displayed in the details number, could I conditionaly only show a sum of fresh fruit? Example below
My problem is this: a manager has to select 2 dates and from those 2 dates he should see all the times a certain movie has been rented FOR EACH MONTH. For example if he picks 11/1/2007 to 2/1/2008 he sees a total for nov, dec, jan etc. I have a uniqueid for movies called the 'upc' and i have the time and date it was rented 'rental time'
I have a stored procedure with parameters @periodStart and @periodEnd. I am just fine getting the total for the period. but I have no idea how to get the totals for each month. The hint i was given was "grouping data ranges." I have no idea how to tackle this
Maybe a case?
Thanks for your help guys. Let me know if any more info would help.
I'll admit I am fairly new to the reporting services, but I managed to figure most things out so far except this one. I have a matrix report where I have column groupings of:
Sales person Region
Basically, the report shows sales by sales person and region, and I added subtotals to each so each salesman/region combination gets subtotals, as does each salesman entry. Now, the one piece missing is the 'total of the subtotals' so to speak. So if I have something like:
Salesman Region Sales Jan Sales Feb Sales Mar 001 A $100 $175 $50
B $100 $200 $100 C $200 $100 $50 Total $400 $475 $200 002 A $100 $175 $50
B $100 $200 $100 C $200 $100 $50 Total $400 $475 $200 Grand Total $800 $950 $400
What I want to do is sum up the totals and add another column like so:
Salesman Region Sales Jan Sales Feb Sales Mar 001 A $100 $175 $50
B $100 $200 $100 C $200 $100 $50 Total $400 $475 $200 $1075 002 A $100 $175 $50
B $100 $200 $100 C $200 $100 $50 Total $400 $475 $200 $1075 Grand Total $800 $950 $400 $2150
And that is where I am stuck. In Report Designer, with the existing matrix report as above, how do I get these horizontal totals of the subtotals?
My problem is this: a manager has to select 2 dates and from those 2 dates he should see all the times a certain movie has been rented FOR EACH MONTH. For example if he picks 11/1/2007 to 2/1/2008 he sees a total for nov, dec, jan etc. I have a uniqueid for movies called the 'upc' and i have the time and date it was rented 'rental time'
I have a stored procedure with parameters @periodStart and @periodEnd. I am just fine getting the total for the period. but I have no idea how to get the totals for each month. The hint i was given was "grouping data ranges." I have no idea how to tackle this
Maybe a case?
Thanks for your help guys. Let me know if any more info would help.
I'm working with parent-child hierarchies. My source is AS2005. What I have now is: + parent 1 child 1.1 child 1.2 child 1.3 + parent 2 child 2.1 child 2.2
What I would like is: child 1.1 child 1.2 child 1.3 + parent 1 child 2.1 child 2.2 + parent 2
This would allow me to simulate subtotals for the hierarchy in a more financially intuitive way. I call it a simulutation because the optimal solution would be to use a normal group for the parent-child hierarchy and then apply group-headers and -footers. However, this does not seem possible and the documentation I've found also describes parent-child hierarchies wrt. the details-group only.
I have thought sorting the data - perhaps on levels, but I haven't got anything to work yet. One of the things that annoys me the most when developing in RS2005 is that it's very hard to debug the layout. For instance, when I apply sorting - first ascending then descending - and the result is the same I get no messages telling me what's wrong (which there obviously must be...).
I need a sales report that would display weekly amounts either sold or forecasted in matrix (pivot) form.
The data used for the report is like following (INV is sold and FC is forecasted):
rtype region
week
wgt
INV EU 1 150
INV US 2 200
FC US 2 400
FC US 3 1000
FC EU 2 100
I want the report to show data like this:
WEEK 1
WEEK 2
WEEK 3
TOTAL
INV
INV
FC
FC
INV
FC
EU 150
100
150 100
US
200 400 1000 200 1400
So I put region as rows, week and rtype as columns, and wgt as data field. Everything works fine except that there will be no grand totals for INV/FC. What I get is:
WEEK 1 WEEK 2 WEEK 3 TOTAL
INV INV FC FC
EU 150
100
250
US
200 400 1000 1600
How can I get my totals? I know I could tailor my data to get INV/FC values into different columns to show as data fields in matrix report. But in this case, every week would always display 2 columns, which is certainly not what I want.
I also know I could add another matrix report to create a simulated total columns, but I wasn't able to "join" these 2 reports properly, there is always some space between them and the report looks unprofessionally. So I am looking for a way to do that with a single matrix.
Second question: how can I paint entire columns into different colors, so that INV is always green and FC is always blue? I tried customizing background color, but it only paints cells with values inside, leaving empty cells white. Is it possible to have the INV columns green, entirely?
Is there any way to get multiple subtotals in a matrix? For example, one that does a count and the 2nd that does an averages as per the desired result below ...
Code Block
A B C A 1 2 3 B 2 3 4 C 3 4 5 Total 6 9 12 Avg 2 3 4
Seems simple. Â People working in departments with different types of hours (regular, overtime, vacation... thus the grid which pivots hours in rows to the appropriate columns). Â I want to subtotal by department, but whenever I try to add totals after to that group, I just get a grand total. Â No subtotals. Â Why?
I want to have this query insert a bunch of XML but i get this error...
Msg 128, Level 15, State 1, Procedure InsertTimeCard, Line 117
The name "ExpenseRptID" is not permitted in this context. Valid expressions are constants, constant expressions, and (in some contexts) variables. Column names are not permitted.
Msg 128, Level 15, State 1, Procedure InsertTimeCard, Line 151
The name "DateWorked" is not permitted in this context. Valid expressions are constants, constant expressions, and (in some contexts) variables. Column names are not permitted.
What am i doing wrong...Can anyone help me out!! Thanks!!
p.s I know this query looks crazy...
Code Block
IF EXISTS (SELECT NAME FROM sysobjects WHERE NAME = 'InsertTimeCard' AND type = 'P' AND uid=(Select uid from sysusers where name=current_user)) BEGIN DROP PROCEDURE InsertTimeCard END go /********************************************************************************************************* ** PROC NAME : InsertTimeCardHoursWorked ** ** AUTHOR : Demetrius Powers ** ** TODO/ISSUES ** ------------------------------------------------------------------------------------ ** ** ** MODIFICATIONS ** ------------------------------------------------------------------------------------ ** Name Date Comment ** ------------------------------------------------------------------------------------ ** Powers 12/11/2007 -Initial Creation *********************************************************************************************************/ CREATE PROCEDURE InsertTimeCard @DateCreated DateTime, @EmployeeID int, @DateEntered DateTime, @SerializedXML text, @Result int output as declare @NewTimeCardID int select @NewTimeCardID = max(TimeCardID) from OPS_TimeCards -- proc settings SET NOCOUNT ON
-- local variables DECLARE @intDoc int DECLARE @bolOpen bit SET @bolOpen = 0 --Prepare the XML document to be loaded EXEC sp_xml_preparedocument @intDoc OUTPUT, @SerializedXML -- check for error IF @@ERROR <> 0 GOTO ErrorHandler --The document was prepared so set the boolean indicator so we know to close it if an error occurs. SET @bolOpen = 1
--Create temp variable to store values inthe XML document DECLARE @tempXMLTimeCardExpense TABLE ( TimeCardExpenseID int not null identity(1,1), TimeCardID int, ExpenseRptID int, ExpenseDate datetime, ProjectID int, ExpenseDescription nvarchar(510), ExpenseAmount money, ExpenseCodeID int, AttachedRct bit, SubmittoExpRep bit ) DECLARE @tempXMLTimeCardWorked TABLE ( TimeCardDetailID int not null identity(1,1), TimeCardID int, DateWorked DateTime, ProjectID int, WorkDescription nvarchar(510), BillableHours float, BillingRate money, WorkCodeID int, Location nvarchar(50) ) -- begin trans BEGIN TRANSACTION insert OPS_TimeCards(NewTimeCardID, DateCreated, EmployeeID, DateEntered, Paid) values (@NewTimeCardID, @DateCreated, @EmployeeID, @DateEntered, 0) -- check for error IF @@ERROR <> 0 GOTO ErrorHandler
--Now use @intDoc with XPATH style queries on the XML INSERT @tempXMLTimeCardExpense (TimeCardID, ExpenseRptID, ExpenseDate, ProjectID, ExpenseDescription, ExpenseAmount, ExpenseCodeID, AttachedRct, SubmittoExpRep) SELECT @NewTimeCardID, ExpenseRptID, ExpenseDate, ProjectID, ExpenseDescription, ExpenseAmount, ExpenseCodeID, AttachedRct, SubmittoExpRep FROM OPENXML(@intDoc, '/ArrayOfTimeCardExpense/TimeCardExpense', 2) WITH ( ExpenseRptID int 'ExpenseRptID', ExpenseDate datetime 'ExpenseDate', ProjectID int 'ProjectID', ExpenseDescription nvarchar(510) 'ExpenseDescription', ExpenseAmount money 'ExpenseAmount', ExpenseCodeID int 'ExpenseCodeID', AttachedRct bit 'AttachedRct', SubmittoExpRep bit 'SubmittoExpRep') -- check for error IF @@ERROR <> 0 GOTO ErrorHandler
-- remove XML doc from memory EXEC sp_xml_removedocument @intDoc SET @bolOpen = 0
-- commit transaction, and exit COMMIT TRANSACTION set @Result = @NewTimeCardID RETURN 0
-- Error Handler ErrorHandler: -- see if transaction is open IF @@TRANCOUNT > 0 BEGIN -- rollback tran ROLLBACK TRANSACTION END -- set failure values SET @Result = -1 RETURN -1
Firstly thanks a lot Phil and Jamie on such a helpful article on "Checking to see if a record exists and if so update else insert"
Here is my question
I have about 10 tables and there respective working tables For examples: A, B, C, D, E.... and WorkA, WorkB, WorkC....
Notes: 1) When I execute a package these work table (Work A, WorkB ...) get populated with certain rows say about 5 2) Its not that all the work table are populated on every execution. 3) Tables A, B, C... have thousands of records in it. 4) Work table is of same structure as there parent table..Like WorkA same structure as A..... 5) The table A and WorkA and as on... are linked with a KeyID
Now I want to build a SSIS package that can 1) Get the the data from these multiple tables(WorkA, WorkB...) 2) Process each row of these tables WorkA, WorkB.. 3) Depending upon the KEYID of WorkA., WorkB.. etc Update a Flag colunm of table A, B...where the KeyID is equal to KeyID of Work Table 4) After updating insert that processed row of Work A, WorkB ...into Table A, B..
I can do this if I have one source table and one destination table. Here i have some say 10 randomly source tables to respective random destination . All I could think of creating 10 different packages as adviced in Jamie's article. But I am sure there might some other alternative.
Can somebody advice me the best practice of doing this. Thanks a lot in advance