Sort columns in matrix report
Hi all
I create matrix report( in version 9i)
I want sort columns of report
when i use order by it sort rows but i want sort columns
my query is like this:
SELECT
Code,
name,
DECODE(cons_code, '1', 'A',
'2', 'B',
'3','C',
'4', 'D',
'5', 'E') Activity,
SUM(amnt) amount
From Mytable
Where ....
group by
Code,
DECODE(cons_code, '1', 'A',
'2', 'B',
'3','C',
'4', 'D',
'5', 'E')
my group base on code
my columns base on Activity
and cells are Amount
my report result is:
........ B E D A C
name1 1 1 1 1 2
name2 3 4 8 6 1
I want this :
........ A B C D E
name1 1 1 1 1 2
name2 3 4 8 6 1
....
Hello,
How about this?
SELECT Code, name,
DECODE(cons_code, '1', 'A', '2', 'B', '3','C', '4', 'D','5', 'E') Activity, SUM(amnt) amount
From Mytable
WHERE ....
GROUP BY Code, name, DECODE(cons_code, '1', 'A', '2', 'B', '3','C', '4', 'D', '5', 'E')
ORDER BY code, DECODE(cons_code, '1', 'A', '2', 'B', '3','C', '4', 'D', '5', 'E')
Similar Messages
-
How can I get (using API) the current sort column for some report
hello,
How can I get (using API) the current sort column for some report ? For example something like "fsp_sort_1_desc" - if the user sorts by the first column ?
I cannot use the :REQUEST for this, sometimes the current sort column is not in the :REQUEST, but it is still active.
I thought it was posssible by using
APEX_UTIL.GET_PREFERENCE (
p_preference IN VARCHAR2 DEFAULT NULL,
p_user IN VARCHAR2 DEFAULT V('USER'))
RETURN VARCHAR2;
function, but I don't really know which preference should I pass as parameter.
looking in WWV_FLOW_PREFERENCES$, i saw preferences_names like FSP4000_P527_R6281510839654570_SORT , I'm not sure how this name is formed.
I'm using generic columns for that complex report (which has a flexible number of columns shown), and the idea is that sometimes I have to overwrite that sort column, in case the user chose the version of the report with fewer columns than the previous one.
Can I get (using API) a list of all preferences set for some user ?
Thank you,seems that it is FSP<app_number>P<pagenumber>R<regionnumber>_SORT.
is there anyplace where I can get these kind of things documented ?
Thank you. -
Howto use formula columns in matrix reports
Hello
How can i use a formula column in matrix report whose function would be
Formula_Column_Result=A-B where A=Cell A
B =Cell B
Regards
FahadHii guys
I solved my problem on my own.
i wrote
SELECT * FROM EMP WHERE EMP.DEPTNO=P_DEPT_NO
and it worked.
Thanks guys..i luv this forum
Regards
Fahad Hameed -
SSRS 2005 - Dynamically control the width of columns in Matrix report or Hide any column
Hi All,
I just want to hide some column without having white space in Matrix report in SSRS 2005. Although I am aware of that perhaps this feature is not available on SSRS 2005. So, I just want to know if we can handle the width of column dynamically(using expressions)
in matrix report?
Please help. Thanks in Advance.
Regards
KumudHi Kumud,
Based on my test, SSRS is not support column dynamically width. It has property “CanGrow” of text box. If we configure the property to True, it will wraps to next line if needed. In SSRS 2008, we can hide some columns without white space. If possible, I
recommend you update your SSRS 2005 to SSRS 2008.
There is a similar issue, you can refer to it.
http://social.msdn.microsoft.com/Forums/sqlserver/en-US/9e6043f1-c458-4540-be59-d37b02feab8a/dynamic-column-width-for-a-report?forum=sqlreportingservices
Alternatively, I recommend you that submit a wish to the Microsoft Connect at
https://connect.microsoft.com/SQLServer/Feedback. Your feedback is valuable for us to improve our products and increase the level of service provided.
Regards,
Alisa Tang
Alisa Tang
TechNet Community Support -
: HIDING SUMMARY COLUMNS IN MATRIX REPORT , URGENT
Hi,
Can any one please tell me how to hide a column in oralce matrix report. Its a summary column for the matrix report which appears next to the cell values. For example
Manufacturer
Brand
SubBrand1 SubBrand2 Brand Total Manufacturer Total
Week $ Sales $ Sales Total $ Sales Total $ Sales
This is a case where,the cell value is the $ sales for the SubBrand for the week. And it gets total at each brand level and each Manufacturer level. The requrement is if there is only one SubBrand for a Brand then the Brand total should not appear on the report. Similarly if there is one Brand for a Manufacturer, then the total at Manufacturer level should not appear . The point is not only it should dissapear but the frame should srink to make it fell that there is no totaling going on at those two levels. If the fileds just remains blank then the report looks odd. So the gap should be srinked as well. How to do it . This is very urgent . Please help me out.
Thanks
Ferozuse a formst trigeer on the field that returns false when you don't want to display the field.
-
Display null rows / columns in matrix report
Hi,
Is it possible to display any character ('0' for example) in a matrix report where the entire row or column show no value at all ?
My matrix shows Row1 and Row2 with values but no Row3 at all like this:
Column1 Column2 Column3
Row1 value1 value2 value3
Row2 value4 value5 value6
But I would like it to show my rows 3 with '0's :
Column1 Column2 Column3
Row1 value1 value2 value3
Row2 value4 value5 value6
Row3 0 0 0
Thank you,
DeniseMake your query return 0 with nvl(column, 0) and an outer join, plus some stuff to avoid a double outer join.
E.g. a sales per product per city:
City1 City2 City3
Prod1 10 100 12
Prod2 25 110 200
Prod3 0 0 0Could be made like this:
create table city (c_city varchar2(10));
create table prod (p_prod varchar2(10));
create table prod_sales (ps_city varchar2(10)
, ps_prod varchar2(10)
, ps_sales number);
<.....insert some values, except voor Prod3 .....>
SQL> select p_prod, c_city, nvl(ps_sales,0)
2 from (select c_city, p_prod from city, prod)
3 , prod_sales
4 where ps_city(+) = c_city
5 and ps_prod(+) = p_prod
6 order by 1,2 ;
P_PROD C_CITY NVL(PS_SALES,0)
Prod1 City1 10
Prod1 City2 100
Prod1 City3 12
Prod2 City1 25
Prod2 City2 110
Prod2 City3 200
Prod3 City1 0
Prod3 City2 0
Prod3 City3 0 -
Formula Column in Matrix Report (Running Balance)
Hi all. I hope somebody can help me.
I am working on a matrix report using multi-query data models. The report has 2 groups in the horizontal axis and 3 groups in the vertical axis. The intersection is not just a single row but may consist of multiple rows.
My problem is this. I want to create a column in the intersection which is obtained by using a column value from the lowest group in the vertical axis and a summary column obtained from the rows of the intersection.
Here's what my report looks like:
2002 (accross)
2002(down) january february (accross)
January (down) payments balance payments balance
loan #1 10,000 500 9,000 200 8,800
500
loan #2 5,000 100 4,900 200 4,700
February
loan #3 3,500 0 3,500 50 3,450
loan #4 4,200 0 4,200 0 4,200
As you can see, the loans are grouped by month and year. And the payments are grouped for the month and year too.
The data model is :
For Query 1 (Vertical Axis),
1st group - Loan Yr
2nd group - Loan Mo
3rd group - Loan # and amount
For Query 2 (Horizontal Axis)
1st group - Payment Yr
2nd group - Payment Mo
Intersection Group - Payment Amount
My problem actually is how to compute for the running balance of the loan for each month in the horizontal axis. Ive already created a cross product summary to get the running total of the payments made for the month. I tried creating a formula column to for the running balance by subtracting it from the loan amount but i get the error "incompatible frequency"
I hope i have described my problem well and thanks for the helpThe problem is that you're trying to reference dimension columns(loan Amount) in the calculation of matrix cell values. You can only reference other matrix cell values or cross product columns (summary, formula, placeholders) when calculating matrix cell values. Try moving the (loan Amount) column down to the matrix cell - something like:
For Query 1 (Vertical Axis),
1st group - G_LoanYear(LoanYr)
2nd group - G_LoanMonth(LoanMo)
3rd group - G_LoanNumber(Loan#)
For Query 2 (Horizontal Axis)
1st group - G_PaymentYear(PaymentYr)
2nd group - G_PaymentMonth(PaymentMo)
Intersecion /Detail Group - G_Details(PaymentAmount, LoanAmount)
Then create the following Matrix summary columns:
A running summary - CS_Payments:
- Product Order: G_LoanYear G_LoanMonth G_LoanNumber G_PaymentYear G_PaymentMonth
- Source: PaymentAmount
- Function: Sum
- Reset At: G_LoanNumber
The total amount per loan - CS_TotalPayment:
- Product Order: G_LoanYear G_LoanMonth G_LoanNumber
- Source: LoanAmount
- Function: First
- Reset At: G_LoanNumber
The value of the loan after each payment - CF_Countdown:
- Product Order: G_LoanYear G_LoanMonth G_LoanNumber G_PaymentYear G_PaymentMonth
- PL/SQL Formula:
function CF_CountdownFormula return Number is
begin
return(:CS_TotalPayment - :CS_Payments);
end;
You should then be able to display "CF_Payments" and "CF_Countdown" in the matrix cell to show how much has been paid and how much is still owed.
You can still have another "loan amount" as a dimension column - you just don't need to use it when calculating the values in the cell. -
Problem in specifing the intial sorting column of a report
hi
we have a report based on a table with 6 columns in our home page .we display all the six columns as sortable.
we also need to sort the contents of the report by 4th column by default when ever the user logs in ,but what happens is ,report gets sorted automatically depening upon the previous sorting column selected
is there any way of telling htmldb to sort the report by 4th column ..
many thanks
S.Jawaharhi ,
this infotype has a interesting solution . In my case it was for US country .
We select the veteran status and this is field P0077-VETST which is stored in DB table .
Now based on this value and the molga of that pernr we need to look at the T5UVT table for the combinations avaliable for MOLGA AND VETST .
Based on the config's of this table the screen values are getting populated .
It dosent allow any combinations and the picked values are passed to the screen for fields Q0077-VETS1 VETS2 VETS3 VETS4 .
Br,
Vijay. -
How to sort data in Matrix report
I've used Report6i and create report in Matrix format.I want the report to display data in sorting by data in cell. Anyone pls help me.
--it's show this
applicant_id/score Score
08002 400
08003 200
08004 700
08006 653
08008 560
08010 800
-- but i want to see this
applicant_id/score Score
08010 800
08004 700
08006 653
08008 560
08002 400
08003 200
i tried to set the group's property( break order property ). It doesn't allow me to set break order property of applicant_id's group to none. And tried to write 'order by' in the SQL statement but it doesn't help.Hi,
If Oracle can give you back the right sort order without any custom sorting,
that means you should be able to get the same results in WebI.
If the object that you pull from the universe is the wrong type (like numeric but you want it alphanumeric),
then you can either request you designer to give you an object with the right data type,
or you can change it by creating a report variable using
FormatNumber([original object],"0")
this will format the number to a number without leading zeroes, thousand separators or decimal point.
Now you can use the object as if it came from the universe.
So you can also use it on the x-axis of a chart.
Btw. you can also do a custom sort on the x-axis(as long as it is an object or variable, not a formula)
alternative, if you define a custom sort in a table block, you can state it should be used througout the document.
(so also in the charts.
Hope this helps,
Marianne -
i make a matrix report and the data is arabic
when i make concurrent pdf or html the arabic is not appear as i want.
when i try to make a template i can't because the option is table or table/form.
what is the solution?You need to use an outer join in some way. See these similar problems:
Re: Display null rows / columns in matrix report
Re: To obtain all the Month details -
Hello All,
I dynamic columns in matrix reports.
e.g. employee_name,basic pay and etc.....
How i can achieve different size for diffrent item
in my report basic salary columns also becomes same width like employee name !!!!
What is the solution ?
From
Chirag PatelYou can resize fields (columns) by clicking and then dragging the rightmost handle of the selected field. For more information on resizing fileds, refer to Section 25.5 Format monetary values in the "Oracle Reports Buiding Reports" manual, which is available on OTN: http://www.oracle.com/technology/documentation/dev10gR2.html
-
Need help in sorting a alphanumeric DB column in BO report.
Hi All,
We have a DB column (Data type = varchar2).. with values..
1
1
1.1
1.1.1
1.1.1.1
1.2
1.2.1
1.3
1.3.1
1.3.1.1.1
Desired
1
1.1
1.1.1
1.1.1.1
1.2
1.2.1
1.3
1.3.1
1.3.1.1.1
2
etc..
We need to sort this column in BO report.. any idea.. we have sorted it in the Query which is giving right output in pl/sql developer but in BO sorting is not showing properly.
Could you help please to achieve this?
Thanks and Regards,
PriyashreeThe Record Sort Expert appears when you choose the Record Sort Expert command from the Report menu.
Use the Record Sort Expert to define how you want the records in your report to be sorted for printing. You can add and remove a sort field and define the sort direction (ascending or descending) for the data in your report.
In my version Record Sort appears as a A over a Z with Arrows pointing from A to Z, and Z to A. It is next to group expert, which looks like a mountain with an arrow pointing up. Both are on the "Expert" tool bar. -
Matrix report with dynamic and fixed columns
Hi all,
I have a matrix report which has dynamic as well as few fixed columns.
It is a fixed asset Report in which the sum(cost) in cell should be grouped according to column and row-wise.
The row consists of the activity such as additions, retirements etc and the dynamic column is the category and other fixed columns such as CIP cost, CWIP cost will be grouped only according to row.
the actual layout should be like this
| category 1 | category 2 | category 3 ...... | CIP cost | CWIP cost
Additions | Sum(cost) | Sum(cost) | Sum(cost) .......| 1234 | 4500
retirements | Sum(cost) | Sum(cost) | Sum(cost) .......| 1000 | 2500but due to fixed colums in the layout the report builder pushes the fixed colums to the next row with single query i get
| category 1 | category 2 | category 3 ...... |
Additions | Sum(cost) | Sum(cost) | Sum(cost) .......|
CIP cost | CWIP cost
1234 | 4500
retirements | Sum(cost) | Sum(cost) | Sum(cost) .......|
CIP cost | CWIP cost
1000 | 2500if i try to add those columns alone in a seperate query and then build the report i get the layout like this
| category 1 | category 2 | category 3 ...... |
Additions | Sum(cost) | Sum(cost) | Sum(cost) .......|
retirements | Sum(cost) | Sum(cost) | Sum(cost) .......|
CIP cost | CWIP cost
2234 | 7000This is my query, i have used union to get the row-wise column activity
/* Formatted on 03-Sep-12 5:23:11 PM (QP5 v5.114.809.3010) */
SELECT DISTINCT /*ASSET_ID
SUM (cost),
SUM (cip_cost),
SUM (cip_cost_pk),
cat_desc--,sub_cat_desc
,activity
FROM (-- cip cost
SELECT DISTINCT asset_id,
cost,
ytd_deprn,
deprn_amount,
deprn_reserve acc_deprn,
cost - deprn_reserve net_bk_val,
cip_cost,
cip_cost_pk,
description cat_desc,
fat_desc sub_cat_desc,
activity
FROM (SELECT DISTINCT
fb.asset_id,
fb.cost,
facc.cost cip_cost,
0 cip_cost_pk,
ds.ytd_deprn,
ds.deprn_reserve,
fc.description,
fat.description fat_desc,
ds.deprn_amount,
DECODE (
facc.asset_type
|| '-'
|| fc.segment1
|| '-'
|| di.transtype,
'CIP'
|| '-'
|| fc.segment1
|| '-'
|| 'TRANSFER',
'CIP T/F',
'CIP-0012-' || di.transtype,
'Additions Project Khalifa assets',
'CAPITALIZED-' || fc.segment1 || di.transtype,
'0',
'Additions'
activity
FROM fa_books fb,
fa_additions_b fa,
fa_methods fm,
fa_financial_inquiry_cost_v fic,
fa_categories_vl fc,
fa_capitalize_cip_v facc,
fa_additions_tl fat,
fa_deprn_summary ds,
fa_distribution_inquiry_v di
WHERE ds.asset_id = fa.asset_id
AND fb.asset_id = fa.asset_id
AND fb.asset_id = fic.asset_id
AND di.asset_id = fb.asset_id
AND fb.life_in_months = fm.life_in_months
AND fb.book_type_code = ds.book_type_code
AND fb.book_type_code = fic.book_type_code
AND fa.last_update_date >
TO_DATE (
'01'
|| 'JAN'
|| TO_CHAR (SYSDATE, 'RRRR'),
'DD-MON-RRRR'
AND ds.deprn_run_date =
(SELECT DISTINCT MAX (deprn_run_date)
FROM fa_deprn_summary
WHERE asset_id = fb.asset_id)
AND fic.transaction_header_id_in =
(SELECT DISTINCT
MAX (transaction_header_id_in)
FROM fa_financial_inquiry_cost_v
WHERE asset_id = fb.asset_id)
AND fb.date_effective =
(SELECT DISTINCT MAX (date_effective)
FROM fa_books
WHERE asset_id = fb.asset_id)
AND di.transaction_header_id =
(SELECT DISTINCT
MAX (transaction_header_id)
FROM fa_distribution_inquiry_v
WHERE asset_id = fb.asset_id)
AND fa.attribute_category_code =
fc.segment1 || '-' || fc.segment2
AND fc.segment1 <> '0012'
AND fb.asset_id = facc.asset_id
AND fa.asset_id = fat.asset_id
--AND facc.asset_type <> 'CAPITALIZED'
AND fb.deprn_method_code = fm.method_code
AND ds.deprn_source_code <> 'BOOKS'
AND DECODE (
facc.asset_type || '-' || fc.segment1,
'CIP-0012',
'Additions Project Khalifa assets',
'CAPITALIZED-' || fc.segment1,
'0',
'Additions'
) <> '0'/*ORDER BY fb.asset_id*/
UNION
--cip cost pk
SELECT DISTINCT asset_id,
cost,
ytd_deprn,
deprn_amount,
deprn_reserve acc_deprn,
cost - deprn_reserve net_bk_val,
cip_cost,
cip_cost_pk,
description cat_desc,
fat_desc sub_cat_desc,
activity
FROM (SELECT DISTINCT
fb.asset_id,
fb.cost,
0 cip_cost,
facc.cost cip_cost_pk,
ds.ytd_deprn,
ds.deprn_reserve,
fc.description,
fat.description fat_desc,
ds.deprn_amount,
DECODE (
facc.asset_type
|| '-'
|| fc.segment1
|| '-'
|| di.transtype,
'CIP'
|| '-'
|| fc.segment1
|| '-'
|| 'TRANSFER',
'CIP T/F',
'CIP-0012-' || di.transtype,
'Additions Project Khalifa assets',
'CAPITALIZED-' || fc.segment1 || di.transtype,
'0',
'Additions'
activity
FROM fa_books fb,
fa_additions_b fa,
fa_methods fm,
fa_financial_inquiry_cost_v fic,
fa_categories_vl fc,
fa_capitalize_cip_v facc,
fa_additions_tl fat,
fa_deprn_summary ds,
fa_distribution_inquiry_v di
WHERE ds.asset_id = fa.asset_id
AND fb.asset_id = fa.asset_id
AND fb.asset_id = fic.asset_id
AND di.asset_id = fb.asset_id
AND fb.life_in_months = fm.life_in_months
AND fb.book_type_code = ds.book_type_code
AND fb.book_type_code = fic.book_type_code
AND fa.last_update_date >
TO_DATE (
'01'
|| 'JAN'
|| TO_CHAR (SYSDATE, 'RRRR'),
'DD-MON-RRRR'
AND ds.deprn_run_date =
(SELECT DISTINCT MAX (deprn_run_date)
FROM fa_deprn_summary
WHERE asset_id = fb.asset_id)
AND fic.transaction_header_id_in =
(SELECT DISTINCT
MAX (transaction_header_id_in)
FROM fa_financial_inquiry_cost_v
WHERE asset_id = fb.asset_id)
AND fb.date_effective =
(SELECT DISTINCT MAX (date_effective)
FROM fa_books
WHERE asset_id = fb.asset_id)
AND di.transaction_header_id =
(SELECT DISTINCT
MAX (transaction_header_id)
FROM fa_distribution_inquiry_v
WHERE asset_id = fb.asset_id)
AND fa.attribute_category_code =
fc.segment1 || '-' || fc.segment2
AND fc.segment1 = '0012'
AND fb.asset_id = facc.asset_id
AND fa.asset_id = fat.asset_id
--AND facc.asset_type <> 'CAPITALIZED'
AND fb.deprn_method_code = fm.method_code
AND ds.deprn_source_code <> 'BOOKS'
AND DECODE (
facc.asset_type || '-' || fc.segment1,
'CIP-0012',
'Additions Project Khalifa assets',
'CAPITALIZED-' || fc.segment1,
'0',
'Additions'
) <> '0'/*ORDER BY fb.asset_id*/
UNION
-- Disposal / Transferred / Retired
( -- retired
SELECT DISTINCT asset_id,
cost,
ytd_deprn,
deprn_amount,
deprn_reserve acc_deprn,
cost - deprn_reserve net_bk_val,
cip_cost,
cip_cost_pk,
description cat_desc,
fat_desc sub_cat_desc,
activity
FROM (SELECT DISTINCT
fb.asset_id,
fb.cost,
0 cip_cost,
0 cip_cost_pk,
ds.ytd_deprn,
ds.deprn_reserve,
fc.description,
fat.description fat_desc,
ds.deprn_amount,
'Disposal / Transferred / Retired' activity
FROM fa_books fb,
fa_additions_b fa,
fa_methods fm,
fa_financial_inquiry_cost_v fic,
fa_categories_vl fc,
fa_additions_tl fat,
fa_deprn_summary ds,
fa_mass_ext_retirements_v ret
WHERE ds.asset_id = fa.asset_id
AND fb.asset_id = fa.asset_id
AND fb.asset_id = fic.asset_id
AND fb.life_in_months = fm.life_in_months
AND fb.book_type_code = ds.book_type_code
AND fb.book_type_code = fic.book_type_code
AND fa.last_update_date >
TO_DATE (
'01'
|| 'JAN'
|| TO_CHAR (SYSDATE, 'RRRR'),
'DD-MON-RRRR'
AND ds.deprn_run_date =
(SELECT DISTINCT MAX (deprn_run_date)
FROM fa_deprn_summary
WHERE asset_id = fb.asset_id)
AND fic.transaction_header_id_in =
(SELECT DISTINCT
MAX (transaction_header_id_in)
FROM fa_financial_inquiry_cost_v
WHERE asset_id = fb.asset_id)
AND fb.date_effective =
(SELECT DISTINCT MAX (date_effective)
FROM fa_books
WHERE asset_id = fb.asset_id)
AND fa.attribute_category_code =
fc.segment1 || '-' || fc.segment2
AND fb.asset_id = ret.asset_id
AND fa.asset_id = fat.asset_id
AND fb.deprn_method_code = fm.method_code
AND ds.deprn_source_code <> 'BOOKS'/*ORDER BY fb.asset_id*/
UNION
--transfer
SELECT DISTINCT asset_id,
cost,
ytd_deprn,
deprn_amount,
deprn_reserve acc_deprn,
cost - deprn_reserve net_bk_val,
cip_cost,
cip_cost_pk,
description cat_desc,
fat_desc sub_cat_desc,
activity
FROM (SELECT DISTINCT
fb.asset_id,
fb.cost,
facc.cost cip_cost,
0 cip_cost_pk,
ds.ytd_deprn,
ds.deprn_reserve,
fc.description,
fat.description fat_desc,
ds.deprn_amount,
'Disposal / Transferred / Retired' activity
FROM fa_books fb,
fa_additions_b fa,
fa_methods fm,
fa_financial_inquiry_cost_v fic,
fa_categories_vl fc,
fa_capitalize_cip_v facc,
fa_additions_tl fat,
fa_deprn_summary ds,
fa_distribution_inquiry_v di
WHERE ds.asset_id = fa.asset_id
AND fb.asset_id = fa.asset_id
AND fb.asset_id = fic.asset_id
AND di.asset_id = fb.asset_id
AND fb.life_in_months = fm.life_in_months
AND fb.book_type_code = ds.book_type_code
AND fb.book_type_code = fic.book_type_code
AND fa.last_update_date >
TO_DATE (
'01'
|| 'JAN'
|| TO_CHAR (SYSDATE, 'RRRR'),
'DD-MON-RRRR'
AND ds.deprn_run_date =
(SELECT DISTINCT MAX (deprn_run_date)
FROM fa_deprn_summary
WHERE asset_id = fb.asset_id)
AND fic.transaction_header_id_in =
(SELECT DISTINCT
MAX (transaction_header_id_in)
FROM fa_financial_inquiry_cost_v
WHERE asset_id = fb.asset_id)
AND fb.date_effective =
(SELECT DISTINCT MAX (date_effective)
FROM fa_books
WHERE asset_id = fb.asset_id)
AND di.transaction_header_id =
(SELECT DISTINCT
MAX (transaction_header_id)
FROM fa_distribution_inquiry_v
WHERE asset_id = fb.asset_id
AND transtype = 'TRANSFER')
AND fa.attribute_category_code =
fc.segment1 || '-' || fc.segment2
AND fb.asset_id = facc.asset_id
AND fa.asset_id = fat.asset_id
AND facc.asset_type = 'CAPITALIZED'
AND fb.deprn_method_code = fm.method_code
AND ds.deprn_source_code <> 'BOOKS'/*ORDER BY fb.asset_id*/
GROUP BY cat_desc, activity
ORDER BY activityBrgds,
MaxHi all,
I have a matrix report which has dynamic as well as few fixed columns.
It is a fixed asset Report in which the sum(cost) in cell should be grouped according to column and row-wise.
The row consists of the activity such as additions, retirements etc and the dynamic column is the category and other fixed columns such as CIP cost, CWIP cost will be grouped only according to row.
the actual layout should be like this
| category 1 | category 2 | category 3 ...... | CIP cost | CWIP cost
Additions | Sum(cost) | Sum(cost) | Sum(cost) .......| 1234 | 4500
retirements | Sum(cost) | Sum(cost) | Sum(cost) .......| 1000 | 2500but due to fixed colums in the layout the report builder pushes the fixed colums to the next row with single query i get
| category 1 | category 2 | category 3 ...... |
Additions | Sum(cost) | Sum(cost) | Sum(cost) .......|
CIP cost | CWIP cost
1234 | 4500
retirements | Sum(cost) | Sum(cost) | Sum(cost) .......|
CIP cost | CWIP cost
1000 | 2500if i try to add those columns alone in a seperate query and then build the report i get the layout like this
| category 1 | category 2 | category 3 ...... |
Additions | Sum(cost) | Sum(cost) | Sum(cost) .......|
retirements | Sum(cost) | Sum(cost) | Sum(cost) .......|
CIP cost | CWIP cost
2234 | 7000This is my query, i have used union to get the row-wise column activity
/* Formatted on 03-Sep-12 5:23:11 PM (QP5 v5.114.809.3010) */
SELECT DISTINCT /*ASSET_ID
SUM (cost),
SUM (cip_cost),
SUM (cip_cost_pk),
cat_desc--,sub_cat_desc
,activity
FROM (-- cip cost
SELECT DISTINCT asset_id,
cost,
ytd_deprn,
deprn_amount,
deprn_reserve acc_deprn,
cost - deprn_reserve net_bk_val,
cip_cost,
cip_cost_pk,
description cat_desc,
fat_desc sub_cat_desc,
activity
FROM (SELECT DISTINCT
fb.asset_id,
fb.cost,
facc.cost cip_cost,
0 cip_cost_pk,
ds.ytd_deprn,
ds.deprn_reserve,
fc.description,
fat.description fat_desc,
ds.deprn_amount,
DECODE (
facc.asset_type
|| '-'
|| fc.segment1
|| '-'
|| di.transtype,
'CIP'
|| '-'
|| fc.segment1
|| '-'
|| 'TRANSFER',
'CIP T/F',
'CIP-0012-' || di.transtype,
'Additions Project Khalifa assets',
'CAPITALIZED-' || fc.segment1 || di.transtype,
'0',
'Additions'
activity
FROM fa_books fb,
fa_additions_b fa,
fa_methods fm,
fa_financial_inquiry_cost_v fic,
fa_categories_vl fc,
fa_capitalize_cip_v facc,
fa_additions_tl fat,
fa_deprn_summary ds,
fa_distribution_inquiry_v di
WHERE ds.asset_id = fa.asset_id
AND fb.asset_id = fa.asset_id
AND fb.asset_id = fic.asset_id
AND di.asset_id = fb.asset_id
AND fb.life_in_months = fm.life_in_months
AND fb.book_type_code = ds.book_type_code
AND fb.book_type_code = fic.book_type_code
AND fa.last_update_date >
TO_DATE (
'01'
|| 'JAN'
|| TO_CHAR (SYSDATE, 'RRRR'),
'DD-MON-RRRR'
AND ds.deprn_run_date =
(SELECT DISTINCT MAX (deprn_run_date)
FROM fa_deprn_summary
WHERE asset_id = fb.asset_id)
AND fic.transaction_header_id_in =
(SELECT DISTINCT
MAX (transaction_header_id_in)
FROM fa_financial_inquiry_cost_v
WHERE asset_id = fb.asset_id)
AND fb.date_effective =
(SELECT DISTINCT MAX (date_effective)
FROM fa_books
WHERE asset_id = fb.asset_id)
AND di.transaction_header_id =
(SELECT DISTINCT
MAX (transaction_header_id)
FROM fa_distribution_inquiry_v
WHERE asset_id = fb.asset_id)
AND fa.attribute_category_code =
fc.segment1 || '-' || fc.segment2
AND fc.segment1 <> '0012'
AND fb.asset_id = facc.asset_id
AND fa.asset_id = fat.asset_id
--AND facc.asset_type <> 'CAPITALIZED'
AND fb.deprn_method_code = fm.method_code
AND ds.deprn_source_code <> 'BOOKS'
AND DECODE (
facc.asset_type || '-' || fc.segment1,
'CIP-0012',
'Additions Project Khalifa assets',
'CAPITALIZED-' || fc.segment1,
'0',
'Additions'
) <> '0'/*ORDER BY fb.asset_id*/
UNION
--cip cost pk
SELECT DISTINCT asset_id,
cost,
ytd_deprn,
deprn_amount,
deprn_reserve acc_deprn,
cost - deprn_reserve net_bk_val,
cip_cost,
cip_cost_pk,
description cat_desc,
fat_desc sub_cat_desc,
activity
FROM (SELECT DISTINCT
fb.asset_id,
fb.cost,
0 cip_cost,
facc.cost cip_cost_pk,
ds.ytd_deprn,
ds.deprn_reserve,
fc.description,
fat.description fat_desc,
ds.deprn_amount,
DECODE (
facc.asset_type
|| '-'
|| fc.segment1
|| '-'
|| di.transtype,
'CIP'
|| '-'
|| fc.segment1
|| '-'
|| 'TRANSFER',
'CIP T/F',
'CIP-0012-' || di.transtype,
'Additions Project Khalifa assets',
'CAPITALIZED-' || fc.segment1 || di.transtype,
'0',
'Additions'
activity
FROM fa_books fb,
fa_additions_b fa,
fa_methods fm,
fa_financial_inquiry_cost_v fic,
fa_categories_vl fc,
fa_capitalize_cip_v facc,
fa_additions_tl fat,
fa_deprn_summary ds,
fa_distribution_inquiry_v di
WHERE ds.asset_id = fa.asset_id
AND fb.asset_id = fa.asset_id
AND fb.asset_id = fic.asset_id
AND di.asset_id = fb.asset_id
AND fb.life_in_months = fm.life_in_months
AND fb.book_type_code = ds.book_type_code
AND fb.book_type_code = fic.book_type_code
AND fa.last_update_date >
TO_DATE (
'01'
|| 'JAN'
|| TO_CHAR (SYSDATE, 'RRRR'),
'DD-MON-RRRR'
AND ds.deprn_run_date =
(SELECT DISTINCT MAX (deprn_run_date)
FROM fa_deprn_summary
WHERE asset_id = fb.asset_id)
AND fic.transaction_header_id_in =
(SELECT DISTINCT
MAX (transaction_header_id_in)
FROM fa_financial_inquiry_cost_v
WHERE asset_id = fb.asset_id)
AND fb.date_effective =
(SELECT DISTINCT MAX (date_effective)
FROM fa_books
WHERE asset_id = fb.asset_id)
AND di.transaction_header_id =
(SELECT DISTINCT
MAX (transaction_header_id)
FROM fa_distribution_inquiry_v
WHERE asset_id = fb.asset_id)
AND fa.attribute_category_code =
fc.segment1 || '-' || fc.segment2
AND fc.segment1 = '0012'
AND fb.asset_id = facc.asset_id
AND fa.asset_id = fat.asset_id
--AND facc.asset_type <> 'CAPITALIZED'
AND fb.deprn_method_code = fm.method_code
AND ds.deprn_source_code <> 'BOOKS'
AND DECODE (
facc.asset_type || '-' || fc.segment1,
'CIP-0012',
'Additions Project Khalifa assets',
'CAPITALIZED-' || fc.segment1,
'0',
'Additions'
) <> '0'/*ORDER BY fb.asset_id*/
UNION
-- Disposal / Transferred / Retired
( -- retired
SELECT DISTINCT asset_id,
cost,
ytd_deprn,
deprn_amount,
deprn_reserve acc_deprn,
cost - deprn_reserve net_bk_val,
cip_cost,
cip_cost_pk,
description cat_desc,
fat_desc sub_cat_desc,
activity
FROM (SELECT DISTINCT
fb.asset_id,
fb.cost,
0 cip_cost,
0 cip_cost_pk,
ds.ytd_deprn,
ds.deprn_reserve,
fc.description,
fat.description fat_desc,
ds.deprn_amount,
'Disposal / Transferred / Retired' activity
FROM fa_books fb,
fa_additions_b fa,
fa_methods fm,
fa_financial_inquiry_cost_v fic,
fa_categories_vl fc,
fa_additions_tl fat,
fa_deprn_summary ds,
fa_mass_ext_retirements_v ret
WHERE ds.asset_id = fa.asset_id
AND fb.asset_id = fa.asset_id
AND fb.asset_id = fic.asset_id
AND fb.life_in_months = fm.life_in_months
AND fb.book_type_code = ds.book_type_code
AND fb.book_type_code = fic.book_type_code
AND fa.last_update_date >
TO_DATE (
'01'
|| 'JAN'
|| TO_CHAR (SYSDATE, 'RRRR'),
'DD-MON-RRRR'
AND ds.deprn_run_date =
(SELECT DISTINCT MAX (deprn_run_date)
FROM fa_deprn_summary
WHERE asset_id = fb.asset_id)
AND fic.transaction_header_id_in =
(SELECT DISTINCT
MAX (transaction_header_id_in)
FROM fa_financial_inquiry_cost_v
WHERE asset_id = fb.asset_id)
AND fb.date_effective =
(SELECT DISTINCT MAX (date_effective)
FROM fa_books
WHERE asset_id = fb.asset_id)
AND fa.attribute_category_code =
fc.segment1 || '-' || fc.segment2
AND fb.asset_id = ret.asset_id
AND fa.asset_id = fat.asset_id
AND fb.deprn_method_code = fm.method_code
AND ds.deprn_source_code <> 'BOOKS'/*ORDER BY fb.asset_id*/
UNION
--transfer
SELECT DISTINCT asset_id,
cost,
ytd_deprn,
deprn_amount,
deprn_reserve acc_deprn,
cost - deprn_reserve net_bk_val,
cip_cost,
cip_cost_pk,
description cat_desc,
fat_desc sub_cat_desc,
activity
FROM (SELECT DISTINCT
fb.asset_id,
fb.cost,
facc.cost cip_cost,
0 cip_cost_pk,
ds.ytd_deprn,
ds.deprn_reserve,
fc.description,
fat.description fat_desc,
ds.deprn_amount,
'Disposal / Transferred / Retired' activity
FROM fa_books fb,
fa_additions_b fa,
fa_methods fm,
fa_financial_inquiry_cost_v fic,
fa_categories_vl fc,
fa_capitalize_cip_v facc,
fa_additions_tl fat,
fa_deprn_summary ds,
fa_distribution_inquiry_v di
WHERE ds.asset_id = fa.asset_id
AND fb.asset_id = fa.asset_id
AND fb.asset_id = fic.asset_id
AND di.asset_id = fb.asset_id
AND fb.life_in_months = fm.life_in_months
AND fb.book_type_code = ds.book_type_code
AND fb.book_type_code = fic.book_type_code
AND fa.last_update_date >
TO_DATE (
'01'
|| 'JAN'
|| TO_CHAR (SYSDATE, 'RRRR'),
'DD-MON-RRRR'
AND ds.deprn_run_date =
(SELECT DISTINCT MAX (deprn_run_date)
FROM fa_deprn_summary
WHERE asset_id = fb.asset_id)
AND fic.transaction_header_id_in =
(SELECT DISTINCT
MAX (transaction_header_id_in)
FROM fa_financial_inquiry_cost_v
WHERE asset_id = fb.asset_id)
AND fb.date_effective =
(SELECT DISTINCT MAX (date_effective)
FROM fa_books
WHERE asset_id = fb.asset_id)
AND di.transaction_header_id =
(SELECT DISTINCT
MAX (transaction_header_id)
FROM fa_distribution_inquiry_v
WHERE asset_id = fb.asset_id
AND transtype = 'TRANSFER')
AND fa.attribute_category_code =
fc.segment1 || '-' || fc.segment2
AND fb.asset_id = facc.asset_id
AND fa.asset_id = fat.asset_id
AND facc.asset_type = 'CAPITALIZED'
AND fb.deprn_method_code = fm.method_code
AND ds.deprn_source_code <> 'BOOKS'/*ORDER BY fb.asset_id*/
GROUP BY cat_desc, activity
ORDER BY activityBrgds,
Max -
Hello, Expert,
Could you please help me with the following problem? Thanks in advance!
I have designed the matrix report (SSRS 2012) with database table structure looks like below.
Week
Version
Count
Week1
V1.1
4000
Week1
V1.2
4000
Week1
V1.3
4000
Week2
V1.1
3000
Week2
V1.2
3000
Week2
V1.3
3000
Week3
V1.1
2000
Week3
V1.2
2000
Week3
V1.3
2000
Week4
V1.1
1000
Week4
V1.2
1000
Week4
V1.3
1000
The matrix report displays like below. Column grows based on no of Week in the table.
Week1
Week2
Week3
Week4
V1.1
4000
3000
2000
1000
V1.2
4000
3000
2000
1000
V1.3
4000
3000
2000
1000
What I want to do now is: instead of the Count values, I need to calculate the percentage of each week over the
Count in Week1 so that each cell displays Count(Week2)/Count(Week1), Count(Week3)/Count(Week1), etc. What is the SSRS expression for that? I’m new to SSRS, Please help!Heidi,
Thank you so much for your reply and solution! Now I know how to get the first field in a group. But I can't apply your solution directly just yet because in order to explain my problem I simplified my data structure. My real data structure has a nested
group like this:
Week VersionMajor VersionMinor Count
Week1 V1 V1.1 2000
Week2 V1 V1.1 1500
Week3 V1 V1.1 800
Week1 V1 V1.2 1000
Week2 V1 V1.2 500
Week3 V1 V1.2 200
Week1 V1 V1.1 2000
Week2 V1 V1.1 1500
Week3 V1 V1.1 800
Week1 V1 V1.2 1000
Week2 V1 V1.2 500
Week3 V1 V1.2 200
Here is the query for the above data:
SELECT 'Week1' AS Week, 'V1' AS VersionMajor, 'V1.1' AS VersionMinor, 2000 AS Count
UNION ALL
SELECT 'Week2' AS Week, 'V1' AS VersionMajor, 'V1.1' AS VersionMinor, 1500 AS Count
UNION ALL
SELECT 'Week3' AS Week, 'V1' AS VersionMajor, 'V1.1' AS VersionMinor, 800 AS Count
UNION ALL
SELECT 'Week1' AS Week, 'V1' AS VersionMajor, 'V1.2' AS VersionMinor, 1000 AS Count
UNION ALL
SELECT 'Week2' AS Week, 'V1' AS VersionMajor, 'V1.2' AS VersionMinor, 500 AS Count
UNION ALL
SELECT 'Week3' AS Week, 'V1' AS VersionMajor, 'V1.2' AS VersionMinor, 200 AS Count
UNION ALL
SELECT 'Week1' AS Week, 'V1' AS VersionMajor, 'V1.1' AS VersionMinor, 2000 AS Count
UNION ALL
SELECT 'Week2' AS Week, 'V1' AS VersionMajor, 'V1.1' AS VersionMinor, 1500 AS Count
UNION ALL
SELECT 'Week3' AS Week, 'V1' AS VersionMajor, 'V1.1' AS VersionMinor, 800 AS Count
UNION ALL
SELECT 'Week1' AS Week, 'V1' AS VersionMajor, 'V1.2' AS VersionMinor, 1000 AS Count
UNION ALL
SELECT 'Week2' AS Week, 'V1' AS VersionMajor, 'V1.2' AS VersionMinor, 500 AS Count
UNION ALL
SELECT 'Week3' AS Week, 'V1' AS VersionMajor, 'V1.2' AS VersionMinor, 200 AS Count
And my matrix table looks like this:
What I need to do is to calculate the percentage of each week over week1 for
1) V1 Total
2) V1.1
3) V1.2
I can't use your solution directly because I need to apply Sum function for each cell and the Sum function gives me error when I try to use it on the denominator
First(Fields!Count.Value,"VersionMinor"). If you could help me further to get to the final solution, I'd really appreciate it!!
Happy New Year! -
How to calculate difference and percentage in matrix report dynamic columns in SSRS 2008
Hi Friends,
I need to calculate Difference and Percentage In matrix report SSRS 2008
1) Row grouping based On Product
2) Column Grouping Week and Fiscal Year Current week and Previous Year same Weeks
3)Data Invnetory(Value fileld)
Example:
If value1 and Value2 Available we need to calculate Percentage and Difference.Otherwise Not required NA I need to Show.
For example If Particular week,Current year data is available,Previous year week data is not available No
need to cal Diff and Percentage we need to show Empty.
Below Code is working for If two values is available.
If any one of the fiscal year week data is not there it's taking some garbage values.
I tries with If condition in GetPCT() and GetDiff() It's not working.
Can some one please help me on this.
I am using the custom code
Public Shared Value1 as String
Public Shared Value2 as String
Public Shared previous as string
Public Shared previousweek as string
Public Shared Function GetValue(Value as String,partner as String,Week as String) as String
If partner =previous and Week =previousweek Then
Value2=Value
Else
previous=partner
previousweek=Week
Value1=Value
End If
return Value
End Function
Public Shared Function GetDiff()
return Value2-Value1
End Function
Public Shared Function GetPct()
return (Value2-Value1)/Value1
End Function
How to handle this.
Thank You, Manasa.VHi veerapaneni,
According to your description, if one of the fiscal year week doesn’t have data, the custom code returns false results.
For your requirement, if NULL value exists in the database, we should replace it as zero then perform calculate. So within the code, we should judge whether the value is NULL. To achieve your goal, please refer to the steps below:
1. Create a table like below.
create table dif4
([Product Group] varchar(50),
[Week] varchar(50),
[Fiscalyearweek] varchar(50),
value int
insert into dif4 values
('Desktops','W01','FY14W01',0),
('Desktops','W01','FY15W01',45),
('Desktops','W02','FY14W02',null),
('Desktops','W02','FY15W02',30),
('Desktops','W03','FY14W03',12),
('Desktops','W03','FY15W03',50),
('Notebooks','W01','FY14W01',35),
('Notebooks','W01','FY15W01',56),
('Notebooks','W02','FY14W02',45),
('Notebooks','W02','FY15W02',87),
('Notebooks','W03','FY14W03',75),
('Notebooks','W03','FY15W03',105),
('Tablets','W01','FY14W01',34),
('Tablets','W01','FY15W01',46),
('Tablets','W02','FY14W02',49),
('Tablets','W02','FY15W02',96),
('Tablets','W03','FY14W03',42),
('Tablets','W03','FY15W03',113)
2. Add the custom code in the Report Properties.
Public Shared Value1 as Integer
Public Shared Value2 as Integer
Public Shared previous as string
Public Shared previousweek as string
Public Shared Function GetValue(Value as Integer,product as String,Week as String) as Integer
If Value=Nothing Then
Value=0
End If
If product =previous and Week =previousweek Then
Value2=Value
Else
previous=product
previousweek=Week
Value1=Value
End If
return Value
End Function
Public Shared Function GetPct()
If Value1=0 Then
return 0
Else
return (Value2-Value1)/Value1
End If
End Function
Public Shared Function GetDiff()
return Value2-Value1
End Function
3. Design the matrix like below.
4. Then get the expected results.<o:p></o:p>
If you have any question, please feel free to ask.
Best regards,
Qiuyun Yu
Qiuyun Yu
TechNet Community Support
Maybe you are looking for
-
How can I change the organization information on my trust profile?
I'm re-configuring Lion Server for a company who has changed their name, domain, etc. I have everything updated SSL cert, Code signing cert wise to their new name. However, the trust profile still has the OLD organization name. How can I change this?
-
Which is the best authentication method?
Okay; I'm asking this question a little late as I've already done my implementation and made my choices. Still; It seemed to me the most secure form of authentication for my small ~100 user wireless network was EAP-TLS. My requirements needed me to s
-
Vertical menu CSS issue with IE6,7 & 8
Hello, I am trying to figure out why this code is not working on IE 6,7 and 8, it is working on Firefox, Chrome and others. Could anyone help me find out and fix my problem. I will appreciate it. The code: menu.html <link href="menuVertical.css" rel=
-
Why isn't all my ringtones syncing into my phone?
So I make all my ringtones myself, and they're not all syncing into my phone. Does anyone know why this is happening?
-
How do you find out when your gamer club expires?
how do you find out when your gamer club expires?? Solved! Go to Solution.