Please refer to the below table:
+----------------------------------------------------------+
| +-----------+--------------------+---------------------+ |
| | Company | GL Account | Amount | |
| +-----------+--------------------+---------------------+ |
| | Company 1 | Cash at Bank ANZ | $500,452.22 | |
| +-----------+--------------------+---------------------+ |
| | | Westpac Investment | $443,233.32 | |
| +-----------+--------------------+---------------------+ |
| | | NAB Cheque | $9,833.22 | |
| +-----------+--------------------+---------------------+ |
| | Company 2 | Cash at Bank ANZ | $938.22 | |
| +-----------+--------------------+---------------------+ |
| | | Investment Online | $940,404,400.20 | |
| +-----------+--------------------+---------------------+ |
| | Company 3 | Online Advantage | $93,393.00 | |
| +-----------+--------------------+---------------------+ |
| | | Direct Access | $30.30 | |
| +-----------+--------------------+---------------------+ |
| | | BAR Invest | $192,330,303,300.10 | |
| +-----------+--------------------+---------------------+ |
| | TOTAL | | $193,271,755,580.58 | |
| +-----------+--------------------+---------------------+ |
+----------------------------------------------------------+
This above table is what my SSRS report currently looks like.
As you can see, I have a group of companies. Each company has GL Accounts with multiple transactions however, I am only displaying the total for each GL account. For example, the top amount field "$500,452.22" is a total of ALL transactions for "Cash at Bank ANZ" for "Company 1". Furthermore, I have a total at the bottom, which is the total of ALL amount totals.
I want to add an additional total field which shows the total for ALL amounts fore each company. Basically, the report should look like this:
+----------------------------------------------------------+
| +-----------+--------------------+---------------------+ |
| | Company | GL Account | Amount | |
| +-----------+--------------------+---------------------+ |
| | Company 1 | Cash at Bank ANZ | $500,452.22 | |
| +-----------+--------------------+---------------------+ |
| | | Westpac Investment | $443,233.32 | |
| +-----------+--------------------+---------------------+ |
| | | NAB Cheque | $9,833.22 | |
| +-----------+--------------------+---------------------+ |
| | | TOTAL | $953,518.76 | |
| +-----------+--------------------+---------------------+ |
| | Company 2 | Cash at Bank ANZ | $938.22 | |
| +-----------+--------------------+---------------------+ |
| | | Investment Online | $940,404,400.20 | |
| +-----------+--------------------+---------------------+ |
| | | TOTAL | $940,405,338.42 | |
| +-----------+--------------------+---------------------+ |
| | Company 3 | Online Advantage | $93,393.00 | |
| +-----------+--------------------+---------------------+ |
| | | Direct Access | $30.30 | |
| +-----------+--------------------+---------------------+ |
| | | BAR Invest | $192,330,303,300.10 | |
| +-----------+--------------------+---------------------+ |
| | | TOTAL | $192,330,396,723.40 | |
| +-----------+--------------------+---------------------+ |
| | TOTAL | | $193,271,755,580.58 | |
| +-----------+--------------------+---------------------+ |
+----------------------------------------------------------+
Every time I try to create this total field, the report just displays duplicates of each GL Account total and not the total of all amounts per company.
Can anyone explain how to add the field that I want?
FYI: This is the SQL Query that I used:
select GLAC.GLCo as Company, HQCO.Name as 'Company Name', GLAC.Description as 'GL Description', GLDT.Amount as Amount from GLAC
LEFT JOIN HQCO ON
GLAC.GLCo = HQCO.HQCo
LEFT JOIN GLDT ON
GLAC.GLCo = GLDT.GLCo and GLAC.GLAcct = GLDT.GLAcct
where udCategory = 'Cash At Bank' and Active = 'Y' and (GLAC.GLCo = 1 or GLAC.GLCo = 5 or GLAC.GLCo = 6 or GLAC.GLCo = 7)
Managing groups went from really simple in SSRS 2005 to very difficult and arcane in SSRS 2008. Adding a footer to a group is the least intuitive UX ever.
To create a header or footer after the group has been created, go to the bottom of the design window where the Row Groups panel is. This will show your groups. Drop down the arrow on the Detail group (not the actual group you want to add the footer to but the group inside that) and you will see Add Total with a menu of Before or After. Before adds a header and After adds a footer to the group that encloses the item you are adding the total to.
Once the footer has been created put the expression =SUM(Fields!Amount.Value) into the column and it will sum the amount for your group.
If I recall correctly there is an option in SSRS 2008 R2 to add group sub-totals to a tablix when you add the group.
If you're trying to add them after the fact you can create a group footer row and then put your =SUM(Field!Amount.Value) in the Amount column and just hardcode the TOTAL text in the GL Account column. Since this is still being done inside the scope of the grouping it will only SUM() the values for that group.
I think that , the 'Total' that you are looking will be equal to the sum of all Amount in the data set. I think this should work.
1. Add a subtotal row
2. List item give its expression as SUM(Field!Amount.value)
Grouping in SSRS is certainly not intuitive.
I managed to achieve what I wanted by right clicking in the "Amount" field and then selecting "Insert Row" --> "Outside Group (Below)". I then put the sum in the new cell and everything was calculated how I desired.
Related
How would you design the table(s) to handle a registration form and pricing for an upcoming event?
As seen in the table below:
+-----------------------------+-------------------+----------------+--------------+
| Occupation/Level | Optional Item | Base Price | Early Bird Price |
+-----------------------------+-------------------+------------+------------------+
| Residents | | $1000 | $800 |
+--------------------------------------------------------------+------------------+
| Practitioners | Exam Prep (+$500) | $1500 | $1300 |
+--------------------------------------------------------------+------------------+
| OBYGN Consultant - Friday | | $800 | $900 |
| OBYGN Consultant - Saturday | | $800 | $900 |
| OBYGN Consultant - Sunday | | $600 | $700 |
| OBYGN Consultant - All Days | | $1900 | $2100 |
+-----------------------------+-------------------+------------+------------------+
different prices are charged based on the attendee's occupation.
practitioners have access to an optional exam preparation session for an additional fee
OBGYN Consultants have the option of registering for single/multiple days; each of which charges a different amount
To further illustrate the details, here's a screenshot of the old registration form.
My initial idea is to keep it very simple and treat each line separately and store the amount with it. The days which an OBGYN Consultant may choose simply become another line in the table.
+----+---------------------------+----------------+------------------+
| ID | Occupation/Level | Base Price | Early Bird Price |
+----+---------------------------+----------------+------------------+
| 1 | Residents | $1000 | $800 |
| 2 | Practitioners | $1500 | $1300 |
| 4 | OBYGN_Consultant_Friday | $800 | $900 |
| 5 | OBYGN_Consultant_Saturday | $800 | $900 |
| 6 | OBYGN_Consultant_Sunday | $600 | $700 |
| 7 | OBYGN_Consultant_All_Days | $1900 | $2100 |
+----+---------------------------+----------------+------------------+
The optional_materials table would handle any courses that have additional options.
+----+----------+-----------+--------+
| ID | CourseID | Name | Amount |
+----+----------+-----------+--------+
| 1 | 2 | Exam Prep | $500 |
+----+----------+-----------+--------+
See any major issues with this design OR see a better way of handling it?
Depends on how flexible you want to be in the future. If you for example want to have a super early bird price next year or you will support different currencies then I would make it like this:
+----+----------+---------------------------+------------+-------+----------+
| ID | CourseID | Title | Price Type | Price | Currency |
+----+----------+---------------------------+------------+-------+----------+
| 1 | 1 | Residents | Base | 1000 | Dollar |
| 2 | 1 | Residents | Early | 800 | Dollar |
| 3 | 2 | Practitioners | Base | 1500 | Dollar |
| 4 | 2 | Practitioners | Early | 1300 | Dollar |
| 5 | 4 | OBYGN_Consultant_Friday | Base | 800 | Dollar |
| 6 | 4 | OBYGN_Consultant_Friday | Early | 900 | Dollar |
| 7 | 5 | OBYGN_Consultant_Saturday | Base | 800 | Dollar |
| 8 | 5 | OBYGN_Consultant_Saturday | Early | 900 | Dollar |
| 9 | 6 | OBYGN_Consultant_Sunday | Base | 600 | Dollar |
| 10 | 6 | OBYGN_Consultant_Sunday | Early | 700 | Dollar |
| 11 | 7 | OBYGN_Consultant_All_Days | Base | 1900 | Dollar |
| 12 | 7 | OBYGN_Consultant_All_Days | Early | 2100 | Dollar |
+----+----------+---------------------------+------------+-------+----------+
But overall your approach is totally valid.
Also concider adding a "Created" and "Edited" date field in the end. Makes it easier to keep transparency over data changes (maybe you want to highlight options that are only available or have changed over last 14 days or so)
+--------+---------+----------+----------+-------+------------+------------+
| F Name | L Name | Event ID | Group ID | Hours | Event Type | Event Name |
+--------+---------+----------+----------+-------+------------+------------+
| Bill | Johnson | 1 | | 3 | Event | Indirect |
| Janet | Jackson | | 1 | 1 | Group | |
| Bill | Johnson | | 1 | 1 | Group | |
| Chris | Margot | 2 | | 1.5 | Event | Direct |
| Janet | Jackson | | 1 | 1 | Group | |
+--------+---------+----------+----------+-------+------------+------------+
I have a table like this. I need to calculate the sum of the hours column if the event type is NOT group and direct.
I then need to sum hours if the event type is group but only once per person per group id. (So Janet would have 1 hour for her group not 2 because they have the same group ID. I am getting unexpected results.
I know It will involve a self join. The table is called public.event_by_wkr event_by_wkr in the FROM part of the query. I see this as rather difficult but it may not be. If you need more information I will provide it.
I have two tables (CONTROL & PAYMENT) that looks like this:
CONTROL PAYMENT
+--------------------------+ +------------------------+
| CNUMBER | SERIAL | | NUMBER | STATUS |
+--------------------------+ +------------------------+
| C-200-1 | SUDU-03 | | 200 | PAID |
| C-201-1 | SUDU-03 | | 201 | PAID |
| C-202-1 | SUDU-03 | | 202 | PROCESSING|
| C-203-1 | SUDU-03 | | 203 | PAID |
| C-204-1 | SUDU-03 | | 204 | PROCESSING|
| C-204-1 | SUDU-03 | | 205 | PROCESSING|
+--------------------------+ +------------------------+
I want to show a list like this:
+--------------------------+
| CNUMBER | STATUS |
+--------------------------+
| C-200-1 | PAID |
| C-201-1 | PAID |
| C-202-1 | PROCESSING |
| C-203-1 | PAID |
| C-204-1 | PROCESSING |
| C-205-1 | PROCESSING |
+--------------------------+
So, I need get data (SELECT) from table "control" using "serial" (in control table) like a search criteria to find the "status" (in payment table) through "number" (in payment table) using %LIKE% (to match "number" and "cnumber")
I am trying but still I can't figure it out!
I hope someone can help me and give me any idea.
EDIT:
SOLUTION 1:
select c.CNUMBER,p.STATUS from CONTROL c
inner join PAYMENT p on substr(c.CNUMBER,3,3)=p.NUMBER;
Thanks to #Syscall I solved the main problem but I just have a little issue:
How I can show all the values even payment entries are null/empty ?
If the entry on 'control' exist but in 'payment' not
something like that:
+--------------------------+
| CNUMBER | STATUS |
+--------------------------+
| C-200-1 | PAID |
| C-201-1 | | <--empty
| C-202-1 | PROCESSING |
| C-203-1 | PAID |
| C-204-1 | | <--empty
| C-205-1 | PROCESSING |
+--------------------------+
EDIT 2:
SOLVED, USING LEFT JOIN
Thanks again #Syscall.
SOLUTION:
select c.CNUMBER,p.STATUS from CONTROL c
left join PAYMENT p on substr(c.CNUMBER,3,3)=p.NUMBER WHERE col1 = '$var'
You could INNER JOIN using SUBSTR :
select c.CNUMBER,p.STATUS from CONTROL c
inner join PAYMENT p on substr(c.CNUMBER,3,3)=p.NUMBER;
Outputs :
+---------+------------+
| CNUMBER | STATUS |
+---------+------------+
| C-200-1 | PAID |
| C-201-1 | PAID |
| C-202-1 | PROCESSING |
| C-203-1 | PAID |
| C-204-1 | PROCESSING |
| C-204-1 | PROCESSING |
+---------+------------+
the rank is also using Total value of the column. how to remove that.
it's a calculation.
+---------------------+------------+------+
| Row Labels | Change | Rank |
+---------------------+------------+------+
| ADDERALL XR | 20,236.00 | 7 |
| ATOMOXETINE | 11,448.00 | 9 |
| BIPHENTIN | 87,007.00 | 4 |
| CONCERTA | 151,397.00 | 3 |
| CONCERTA | | 11 |
| DEXEDRINE | 2,065.00 | 10 |
| GENERIC ATOMOXETINE | 17,778.00 | 8 |
| INTUNIV XR | | 12 |
| METHYLPHENIDATE ER | 21,969.00 | 6 |
| METHYPHENIDATE ER | | 13 |
| RITALIN IR | 40,826.00 | 5 |
| RITALIN SR | -19,238.00 | 14 |
| STRATTERA | -19,555.00 | 15 |
| VYVANSE | 220,762.00 | 2 |
| Grand Total | 534,695.00 | 1 |
+---------------------+------------+------+
In the excel sheet, right click on the area where cube data is populated, Click on the Pivot table options, goto Totals and Filters tab, and uncheck grand totals for columns options, and your totals will go off. It will remove totals for all columns, and you will have to sum those columns where you need totals by explicitly writing formulas for those columns.
I've a data that looks like this
| FormCode | Description | MenuPath |
+----------+----------------------+-------------+
| PY | Payroll | |
| PD | Personal Development | |
| EM | EmployeeMaster | PY |
| EB | EmployeeBank | PY |
| ED | EmployeeData | PY |
| Report | Report | PY |
| Badge | Badge Report | PY/Report |
| Process | Process | PY |
| Bonus | Bonus Component | PY/ED |
|Preference| Preference | PY |
| Tax | Tax Result | PY/ED |
|FinalBonus| FinalBonus | PY/ED/Bonus |
| Annual | Annual Process | PY/Process |
|BonusbyCC | Bonus by Cost Centre | PY/ED/Bonus |
| Period | Period |PY/Preference|
I want this data sort to be like this below.
| FormCode | Description | MenuPath |
+----------+----------------------+-------------+
| PY | Payroll | |
| EB | EmployeeBank | PY |
| ED | EmployeeData | PY |
| Bonus | Bonus Component | PY/ED |
|BonusbyCC | Bonus by Cost Centre | PY/ED/Bonus |
|FinalBonus| FinalBonus | PY/ED/Bonus |
| Tax | Tax Result | PY/ED |
| EM | EmployeeMaster | PY |
|Preference| Preference | PY |
| Period | Period |PY/Preference|
| Process | Process | PY |
| Annual | Annual Process | PY/Process |
| Report | Report | PY |
| Badge | Badge Report | PY/Report |
| PD | Personal Development | |
That's the result of the sorting
Explanation :
I will try to explain the sorting. At first we look at the formcode. it will put PY on the first row. After that, there will be the row where MenuPath was PY (sort by alphabeth on the description). In this case EmployeeBank show first. If it doesn't have any child path, the next row will be EmployeeData. after that, EmployeeData has a child like we could see there's Bonus Component(sort by Description) on the next row. After that, if it doesn't have any child, the next row will be Tax Result, but as you can see, Bonus Component still has a child (Bonus by Cost Centre and FinalBonus) so this 2 data will appear after Bonus Component. Tax Result will appear next. The process will keep like that until the end of data.
Sorry if my english messed up and my explanation not good at all. If anyone understand what I mean and could fix my english on the explanation please do it
Thanks for the help
There is absolutely no logic to sort in a way in which you have shown us ..however you can achieve so by assigning some kind of ID to your field and then sort on it
SELECT * FROM Table1
ORDER BY CASE [FormCode]
WHEN 'PY' THEN 1
WHEN 'EM' THEN 2
WHEN 'EB' THEN 3
WHEN 'ED' THEN 4
WHEN 'Bonus' THEN 5
WHEN 'BonusbyCC' THEN 6
WHEN 'FinalBonus' THEN 7
WHEN 'Tax' THEN 8
WHEN 'Preference' THEN 9
WHEN 'Period' THEN 10
WHEN 'Process' THEN 11
WHEN 'Annual' THEN 12
WHEN 'Report' THEN 13
WHEN 'Badge' THEN 14
WHEN 'PD' THEN 15
END;
SAMPLE FIDDLE