Rounding the aggregate function in a pivot table

How do I round the avg(GRADE) when I tried just wrapping it around the avg function I get an error message saying expect aggregate function inside pivot operation
pivot
( avg(GRADE)
for Column
in ('1012222','2221112','333113' );
Thanks for the help.
Edit : Sorry wasn't very clear all thats shown is the pivot part of the statement.
Edited by: 836321 on Feb 13, 2011 8:56 AM
Edited by: 836321 on Feb 13, 2011 8:58 AM

Hi, and welcome to the forum.
It is hard to see how your piece of pseudo SQL is related to your subject title.
There should not be any problem in wrapping ROUND around AVG:
SQL> select deptno, round(avg(sal)) from emp
where deptno in (10,20)
group by deptno
    DEPTNO ROUND(AVG(SAL))
        20            2175
        10            2917
2 rows selected.Edit: Sorry, did not recognize you query bit. You probably are asking about this:
SELECT * FROM
   (SELECT deptno, sal FROM emp)
    PIVOT
   (ROUND(AVG(sal)) FOR deptno IN (10 AS Accounting, 30 AS Sales));
Error at line 4
ORA-56902: expect aggregate function inside pivot operationSuppose you have to (There might be other ways)
SQL> SELECT Round(accounting), round(sales) FROM
   (SELECT deptno, sal FROM emp)
    PIVOT
   (AVG(sal) FOR deptno IN (10 AS Accounting, 30 AS Sales));
ROUND(ACCOUNTING) ROUND(SALES)
             2917         1567
1 row selected.Regards
Peter
Edited by: Peter on Feb 13, 2011 9:05 AM
Edited by: Peter Gjelstrup on Feb 13, 2011 9:08 AM

Similar Messages

  • Customizing the Cell Content of a Pivot Table

    Hi,
    I have been away from ADF for a few years (since 10g v 1.3.1) and am quite impressed with all the Faces functionality added to the 11g release. The application I wrote relied heavily on pivot tables which back then, I had to use stored procedures in the database and dynamically views to display information. I am very interested in moving this application to 11g and taking advantage of the PivotTable component. One thing the application does is change the style of cells based upon the object being presented. I have been reading:
    Oracle® Fusion Middleware
    Web User Interface Developer's Guide for Oracle Application
    Development Framework
    11g Release 1 (11.1.1)
    B31973-03
    And am very interested in section 26.8 Customizing the Cell Content of a Pivot Table.
    I easily created a pivot table and would like to change the formatting of various cells. I created a backing bean for a test page and added the Example 26–4 Sample Code to Change Style and Text Style in a Pivot Table to the bean.
    public CellFormat getDataFormat(DataCellContext cxt)
    CellFormat cellFormat = new CellFormat(null, null, null);
    QDR qdr = cxt.getQDR();
    //Obtain a reference to the product category column.
    Object productCateg = qdr.getDimMember("ProductCategory");
    //Obtain a reference to the product column.
    Object product = qdr.getDimMember("ProductId");
    if (productCateg != null && productCateg.toString().equals("Sales Total"))
    cellFormat.setTextStyle("font-weight:bold")
    cellFormat.setStyle("background-color:#C0C0C0");
    else if (product != null && product.toString().equals("Sales Total")
    cellFormat.setTextStyle("font-weight:bold");
    cellFormat.setStyle("background-color:#C0C0C0");
    return cellFormat;
    Almost verbatim except changed the literals to select data in my use case domain. My question is: How do I invoke this message from my pivot table? I need to pass it a instance of the DataCellContext. The example is great and illustrates what I am looking to do but does not go into the implementation details required. Is there a sample app available for download that demonstrates these capabilities?
    Thanks,
    Jeff
    Edited by: jcapzz on Jun 9, 2011 3:56 PM

    Hello,
    I haven't fully understood your question.
    Is it: How do I call the getDataFormat() method from my pivot table?
    If so , you need to set the dataFormat attribute of your pivot table.
    ex: <dvt:pivotTable id="pt2" var="cellData" varStatus="cellStatus"
    value="#{bindings.YourView.pivotTableModel}"
    headerFormat="#{viewScope.yourBean.getHeaderFormat}"
    *dataFormat="#{viewScope.yourBean.getDataFormat}"*
    contentDelivery="immediate" pivotEnabled="false"
    columnFetchSize="-1" rowFetchSize="-1"
    />
    I also put the *headerFormat* attribute which allows to customize the headers
    I hope I understood your question ;)
    Jack

  • Using aggregate function pulls an additional table in join

    Hello,
    We're facing a wierd scenario whereby using an aggregate function in a report brings an additional table in the query, which should not be included. Please throw some light on this if you have any idea why this would happen. Here are the details
    OBIEE version: 10.1.3.4
    I pull 2 columns in my report - Col1 (numeric column from Dim A), Col2 (date column from Dim B)
    I have already set an implicit fact column in that subject area (Col3 from Fact X)
    Now when I run this report, the FROM clause of the sql correctly shows Dim A, Dim B, Fact X
    Later, I apply a MAX function on Col2 (date column from Dim B). Ideally, the FROM clause of my sql should still be the same. But here is what happens...
    FROM Dim A, Dim B, Fact X, Fact Y (Bridge table).
    Fact Y is a bridge table that we are using in this subject area. But there is no reason why this table should get pulled in this query just by using an aggregate function in it.
    Your thoughts and insights will be highly appreciated.
    Thanks,
    Vahib

    Did you apply MAX in the aggregate function section? If that is the case, OBIEE is forced to consider logical table for Dim B as a fact and brings in Y as a way to resolve the join between two facts.
    Try setting up a new fact and create MAX column there. See if it resolves that problem or not. You may also want to bring Dim B in the LTS of the main fact and create a column with MAX aggregation. That should work too.

  • How change the graph dynamically based on pivot table.

    Hi,
    My Report having pivot table and bar chart. Organization Name column set as pivot table prompts in pivot table.So Organization Name is appear as dropdown list.If i choose the diffrent Organization Names the pivot table data is according to the Organization Name but no changes in chart.How change the Graph dynamically based on pivot table.
    Please help on this.

    ok.I created pivot table with 4 columns and created chart using pivot table chart options but all 4 columns are displaying chart.But I need only 2 column in chart ..unable to edit the only chart in pivot table.Please help on this.Thank you..

  • AGO function error in Pivot Table

    Hi,
    I have a typical time dimension - year, period, week, date. Most of my facts are available at the most detailed level of date however I have some Budget facts that are only available at the week level. When I combine these facts in a report I am having the below problem.
    I use an ago function at the yearweek level ( I needed this so that I can compare week numbers as oppposed to week date ranges which is how the year ago function works - I believe).
    If I have a total on year in my pivot table I get the below error -
    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 22036] Level in AGO function (YearWeek) must be a rollup of (or equivalent to) the measure level (Year). (HY000)
    Has anyone come across this before ?
    Thanks
    Patricia

    I am getting the following error message, not sure how to get rid of this.
    Error Codes: OPR4ONWY:U9IM8TAC:OI2DL65P
    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 22036] Level in AGO function (Fiscal Period) must be a rollup of (or equivalent to) the measure level (Fiscal Year). (HY000)
    SQL Issued: SELECT "GL Calendar"."Fiscal Period" saw_0, "Project Manager"."Project Manager Name" saw_1, Project."Project Number" saw_2, Project."Business Area" saw_3, Project."Business Unit" saw_4, Project."Delivery Ownership" saw_5, Project.Programme saw_6, "Fact - Project Cost".Cost saw_7, "Ago Measures"."MAGO Cost" saw_8, "Fact - Project Cost".Cost-"Ago Measures"."MAGO Cost" saw_9, REPORT_SUM(saw_7 BY ), REPORT_SUM(saw_8 BY ), AGGREGATE(saw_9 BY ) FROM "Project - Cost" WHERE ("GL Calendar"."Fiscal Year" = '2011') ORDER BY saw_0, saw_1, saw_2, saw_3, saw_4, saw_5, saw_6

  • How to display the column into the narrative or section from pivot table

    I have a report. I have the basic number displayed in the pivot table, but missing one column and I need move one column to the top. The column missing (% of tested) should be calculated by column c /column F's last number, ie, F7=48. My desired column would be H3=c3/F48 9/48, H4=c4/F488/48.... But I could not get the number 48 into my formula, because it is the running total of the all column E. These data is in Pivot table.
    I also need display No of Students 74 in the top of the report. I am not able to get this number from pivot table. It is count distinct on student key from the repository.
    I appreciate any help.
    A     B     C     D     E     F     G
    2          # of Questions     Average # Correct     % Correct     Running total no. of test items     No of students
    3     PATTERNS, FUNCTIONS, AND ALGEBRA     9     4.68     51.95     9     74
    4     PROBABILITY AND STATISTICS     8     3.97     49.66     17     74
    5     MEASUREMENT AND GEOMETRY     11     6.11     55.53     28     74
    6     NUMBER AND NUMBER SENSE     8     4.16     52.03     36     74
    7     COMPUTATION AND ESTIMATION     12     8.2     68.36     48     74
    Edited by: user7315022 on Feb 3, 2010 2:28 PM

    I wish it was this easy. I must not explain it right. All the score from each student and each question for each subject and each test is stored in database. The number of question for the subject is the max of the questions for each subject. Basically, it needs 'parittion by'... But in the OBIEE, it would not let me add any 'partition by' in the column formula. Is this true? ie, can you use partition by in the column formula? Here are the query from trace file.
    RqList
    TEST_YEAR_SEASONS.TEST_SEASON_NAME as c1 GB,
    REPORTING_SCHOOL_YEARS.SCHOOL_YEAR as c2 GB,
    MAX_TEST_SCORE:[DAggr(STUDENT_TEST_SCORES.MAX_TEST_SCORE by [ REPORTING_SCHOOL_YEARS.SCHOOL_YEAR, TEST_YEAR_SEASONS.TEST_SEASON_NAME, STUDENT_TEST_SCORES.STDNT_STNDRD_TEST_KEY, STUDENT_TEST_SCORES.STUDENTS_KEY, RPT_TEST_DEFINITIONS.TEST_SUBJECT_NAME, RPT_TEST_DEFINITIONS.TEST_LEVEL_NAME, TEST_SCORE_TYPES.TEST_SCORE_TYPE_NAME, SCHOOLS.SCHOOL_NAME, STUDENT_TEST_SCORES.TEST_SCORE_NUMBER] )] as c3 GB,
    STUDENT_TEST_SCORES.TEST_SCORE_NUMBER as c4 GB,
    DIVISION_TOTAL_TESTS:[DAggr(STUDENT_TEST_SCORES.DIVISION_TOTAL_TESTS by [ REPORTING_SCHOOL_YEARS.SCHOOL_YEAR, TEST_YEAR_SEASONS.TEST_SEASON_NAME, STUDENT_TEST_SCORES.STDNT_STNDRD_TEST_KEY, STUDENT_TEST_SCORES.STUDENTS_KEY, RPT_TEST_DEFINITIONS.TEST_SUBJECT_NAME, RPT_TEST_DEFINITIONS.TEST_LEVEL_NAME, TEST_SCORE_TYPES.TEST_SCORE_TYPE_NAME, SCHOOLS.SCHOOL_NAME, STUDENT_TEST_SCORES.TEST_SCORE_NUMBER] )] as c5 GB,
    RPT_TEST_DEFINITIONS.TEST_SUBJECT_NAME as c6 GB,
    RPT_TEST_DEFINITIONS.TEST_LEVEL_NAME as c7 GB,
    TEST_SCORE_TYPES.TEST_SCORE_TYPE_NAME as c8 GB,
    SCHOOLS.SCHOOL_NAME as c9 GB,
    SUM_TEST_SCORE:[DAggr(STUDENT_TEST_SCORES.SUM_TEST_SCORE by [ REPORTING_SCHOOL_YEARS.SCHOOL_YEAR, TEST_YEAR_SEASONS.TEST_SEASON_NAME, STUDENT_TEST_SCORES.STDNT_STNDRD_TEST_KEY, STUDENT_TEST_SCORES.STUDENTS_KEY, RPT_TEST_DEFINITIONS.TEST_SUBJECT_NAME, RPT_TEST_DEFINITIONS.TEST_LEVEL_NAME, TEST_SCORE_TYPES.TEST_SCORE_TYPE_NAME, SCHOOLS.SCHOOL_NAME, STUDENT_TEST_SCORES.TEST_SCORE_NUMBER] )] as c10 GB,
    SUM_TEST_SCORE:[DAggr(STUDENT_TEST_SCORES.SUM_TEST_SCORE by [ REPORTING_SCHOOL_YEARS.SCHOOL_YEAR, TEST_YEAR_SEASONS.TEST_SEASON_NAME, STUDENT_TEST_SCORES.STDNT_STNDRD_TEST_KEY, STUDENT_TEST_SCORES.STUDENTS_KEY, RPT_TEST_DEFINITIONS.TEST_SUBJECT_NAME, RPT_TEST_DEFINITIONS.TEST_LEVEL_NAME, TEST_SCORE_TYPES.TEST_SCORE_TYPE_NAME, SCHOOLS.SCHOOL_NAME, STUDENT_TEST_SCORES.TEST_SCORE_NUMBER] )] / nullif( COUNT_TEST_SCORE:[DAggr(STUDENT_TEST_SCORES.COUNT_TEST_SCORE by [ REPORTING_SCHOOL_YEARS.SCHOOL_YEAR, TEST_YEAR_SEASONS.TEST_SEASON_NAME, STUDENT_TEST_SCORES.STDNT_STNDRD_TEST_KEY, STUDENT_TEST_SCORES.STUDENTS_KEY, RPT_TEST_DEFINITIONS.TEST_SUBJECT_NAME, RPT_TEST_DEFINITIONS.TEST_LEVEL_NAME, TEST_SCORE_TYPES.TEST_SCORE_TYPE_NAME, SCHOOLS.SCHOOL_NAME, STUDENT_TEST_SCORES.TEST_SCORE_NUMBER] )] , 0) as c11 GB,
    MAX_TEST_SCORE:[DAggr(STUDENT_TEST_SCORES.MAX_TEST_SCORE by [ REPORTING_SCHOOL_YEARS.SCHOOL_YEAR, TEST_YEAR_SEASONS.TEST_SEASON_NAME, STUDENT_TEST_SCORES.STDNT_STNDRD_TEST_KEY, STUDENT_TEST_SCORES.STUDENTS_KEY, RPT_TEST_DEFINITIONS.TEST_SUBJECT_NAME, RPT_TEST_DEFINITIONS.TEST_LEVEL_NAME, TEST_SCORE_TYPES.TEST_SCORE_TYPE_NAME, SCHOOLS.SCHOOL_NAME, STUDENT_TEST_SCORES.TEST_SCORE_NUMBER] )] as c12 GB,
    (SUM_TEST_SCORE:[DAggr(STUDENT_TEST_SCORES.SUM_TEST_SCORE by [ REPORTING_SCHOOL_YEARS.SCHOOL_YEAR, TEST_YEAR_SEASONS.TEST_SEASON_NAME, STUDENT_TEST_SCORES.STDNT_STNDRD_TEST_KEY, STUDENT_TEST_SCORES.STUDENTS_KEY, RPT_TEST_DEFINITIONS.TEST_SUBJECT_NAME, RPT_TEST_DEFINITIONS.TEST_LEVEL_NAME, TEST_SCORE_TYPES.TEST_SCORE_TYPE_NAME, SCHOOLS.SCHOOL_NAME, STUDENT_TEST_SCORES.TEST_SCORE_NUMBER] )] / nullif( COUNT_TEST_SCORE:[DAggr(STUDENT_TEST_SCORES.COUNT_TEST_SCORE by [ REPORTING_SCHOOL_YEARS.SCHOOL_YEAR, TEST_YEAR_SEASONS.TEST_SEASON_NAME, STUDENT_TEST_SCORES.STDNT_STNDRD_TEST_KEY, STUDENT_TEST_SCORES.STUDENTS_KEY, RPT_TEST_DEFINITIONS.TEST_SUBJECT_NAME, RPT_TEST_DEFINITIONS.TEST_LEVEL_NAME, TEST_SCORE_TYPES.TEST_SCORE_TYPE_NAME, SCHOOLS.SCHOOL_NAME, STUDENT_TEST_SCORES.TEST_SCORE_NUMBER] )] , 0)) / nullif( MAX_TEST_SCORE:[DAggr(STUDENT_TEST_SCORES.MAX_TEST_SCORE by [ REPORTING_SCHOOL_YEARS.SCHOOL_YEAR, TEST_YEAR_SEASONS.TEST_SEASON_NAME, STUDENT_TEST_SCORES.STDNT_STNDRD_TEST_KEY, STUDENT_TEST_SCORES.STUDENTS_KEY, RPT_TEST_DEFINITIONS.TEST_SUBJECT_NAME, RPT_TEST_DEFINITIONS.TEST_LEVEL_NAME, TEST_SCORE_TYPES.TEST_SCORE_TYPE_NAME, SCHOOLS.SCHOOL_NAME, STUDENT_TEST_SCORES.TEST_SCORE_NUMBER] )] , 0) * 100 as c13 GB,
    STUDENT_TEST_SCORES.STDNT_STNDRD_TEST_KEY as c14 GB,
    STUDENT_TEST_SCORES.STUDENTS_KEY as c15 GB,
    max(SUM_TEST_SCORE:[DAggr(STUDENT_TEST_SCORES.SUM_TEST_SCORE by [ REPORTING_SCHOOL_YEARS.SCHOOL_YEAR, TEST_YEAR_SEASONS.TEST_SEASON_NAME, RPT_TEST_DEFINITIONS.TEST_SUBJECT_NAME, RPT_TEST_DEFINITIONS.TEST_LEVEL_NAME, SCHOOLS.SCHOOL_NAME] )] by [ REPORTING_SCHOOL_YEARS.SCHOOL_YEAR, TEST_YEAR_SEASONS.TEST_SEASON_NAME, RPT_TEST_DEFINITIONS.TEST_SUBJECT_NAME, RPT_TEST_DEFINITIONS.TEST_LEVEL_NAME, SCHOOLS.SCHOOL_NAME] at_distinct [ ] ) / nullif( max(COUNT_TEST_SCORE:[DAggr(STUDENT_TEST_SCORES.COUNT_TEST_SCORE by [ REPORTING_SCHOOL_YEARS.SCHOOL_YEAR, TEST_YEAR_SEASONS.TEST_SEASON_NAME, RPT_TEST_DEFINITIONS.TEST_SUBJECT_NAME, RPT_TEST_DEFINITIONS.TEST_LEVEL_NAME, SCHOOLS.SCHOOL_NAME] )] by [ REPORTING_SCHOOL_YEARS.SCHOOL_YEAR, TEST_YEAR_SEASONS.TEST_SEASON_NAME, RPT_TEST_DEFINITIONS.TEST_SUBJECT_NAME, RPT_TEST_DEFINITIONS.TEST_LEVEL_NAME, SCHOOLS.SCHOOL_NAME] at_distinct [ ] ) , 0) as c16 GB,
    (max(SUM_TEST_SCORE:[DAggr(STUDENT_TEST_SCORES.SUM_TEST_SCORE by [ REPORTING_SCHOOL_YEARS.SCHOOL_YEAR, TEST_YEAR_SEASONS.TEST_SEASON_NAME, RPT_TEST_DEFINITIONS.TEST_SUBJECT_NAME, RPT_TEST_DEFINITIONS.TEST_LEVEL_NAME, SCHOOLS.SCHOOL_NAME] )] by [ REPORTING_SCHOOL_YEARS.SCHOOL_YEAR, TEST_YEAR_SEASONS.TEST_SEASON_NAME, RPT_TEST_DEFINITIONS.TEST_SUBJECT_NAME, RPT_TEST_DEFINITIONS.TEST_LEVEL_NAME, SCHOOLS.SCHOOL_NAME] at_distinct [ ] ) / nullif( max(COUNT_TEST_SCORE:[DAggr(STUDENT_TEST_SCORES.COUNT_TEST_SCORE by [ REPORTING_SCHOOL_YEARS.SCHOOL_YEAR, TEST_YEAR_SEASONS.TEST_SEASON_NAME, RPT_TEST_DEFINITIONS.TEST_SUBJECT_NAME, RPT_TEST_DEFINITIONS.TEST_LEVEL_NAME, SCHOOLS.SCHOOL_NAME] )] by [ REPORTING_SCHOOL_YEARS.SCHOOL_YEAR, TEST_YEAR_SEASONS.TEST_SEASON_NAME, RPT_TEST_DEFINITIONS.TEST_SUBJECT_NAME, RPT_TEST_DEFINITIONS.TEST_LEVEL_NAME, SCHOOLS.SCHOOL_NAME] at_distinct [ ] ) , 0)) / nullif( max(MAX_TEST_SCORE:[DAggr(STUDENT_TEST_SCORES.MAX_TEST_SCORE by [ REPORTING_SCHOOL_YEARS.SCHOOL_YEAR, TEST_YEAR_SEASONS.TEST_SEASON_NAME, RPT_TEST_DEFINITIONS.TEST_SUBJECT_NAME, RPT_TEST_DEFINITIONS.TEST_LEVEL_NAME, SCHOOLS.SCHOOL_NAME] )] by [ REPORTING_SCHOOL_YEARS.SCHOOL_YEAR, TEST_YEAR_SEASONS.TEST_SEASON_NAME, RPT_TEST_DEFINITIONS.TEST_SUBJECT_NAME, RPT_TEST_DEFINITIONS.TEST_LEVEL_NAME, SCHOOLS.SCHOOL_NAME] at_distinct [ ] ) , 0) * 100 as c17 GB
    DetailFilter: RPT_TEST_DEFINITIONS.TEST_LEVEL_NAME = 'GRADE 5' and SCHOOLS.SCHOOL_NAME = 'GLASGOW MIDDLE' and TEST_SCORE_TYPES.TEST_SCORE_TYPE_NAME = 'RAW SCORE' and TEST_YEAR_SEASONS.TEST_SEASON_NAME = 'SPRING' and REPORTING_SCHOOL_YEARS.SCHOOL_YEAR = '200102' and TESTS.TEST_ID = 'SOL' and TEST_DEFINITIONS.PARENT_TEST_SUBJECT_NAME = 'MATHEMATICS' and STUDENT_TEST_SCORES.TEST_SCORE_NUMBER < 900
    OrderBy: c1 asc, c2 asc, c4 asc, c6 asc, c7 asc, c8 asc, c9 asc, c14 asc, c15 asc
    +++azadams:320000:32001b:----2010/02/03 16:48:36
    -------------------- Sending query to database named tacdev (id: <<51109>>):
    select distinct D1.c5 as c1,
    D1.c4 as c2,
    D1.c9 as c3,
    D1.c14 as c4,
    D1.c12 as c5,
    D1.c6 as c6,
    D1.c7 as c7,
    D1.c15 as c8,
    D1.c8 as c9,
    D1.c11 as c10,
    D1.c11 / decode(D1.c10 , 0 , to_number(null), D1.c10) as c11,
    D1.c9 as c12,
    (D1.c11 / decode(D1.c10 , 0 , to_number(null), D1.c10)) / decode(D1.c9 , 0 , to_number(null), D1.c9) * 100 as c13,
    D1.c13 as c14,
    D1.c16 as c15,
    D1.c3 / decode(D1.c2 , 0 , to_number(null), D1.c2) as c16,
    (D1.c3 / decode(D1.c2 , 0 , to_number(null), D1.c2)) / decode(D1.c1 , 0 , to_number(null), D1.c1) * 100 as c17
    from
    (select max(D1.c1) over (partition by D1.c4, D1.c5, D1.c6, D1.c7, D1.c8) as c1,
    sum(D1.c2) over (partition by D1.c4, D1.c5, D1.c6, D1.c7, D1.c8) as c2,
    sum(D1.c3) over (partition by D1.c4, D1.c5, D1.c6, D1.c7, D1.c8) as c3,
    D1.c4 as c4,
    D1.c5 as c5,
    D1.c6 as c6,
    D1.c7 as c7,
    D1.c8 as c8,
    max(D1.c1) over (partition by D1.c4, D1.c16, D1.c5, D1.c13, D1.c6, D1.c7, D1.c15, D1.c8) as c9,
    sum(D1.c2) over (partition by D1.c4, D1.c16, D1.c5, D1.c13, D1.c6, D1.c7, D1.c15, D1.c8) as c10,
    sum(D1.c3) over (partition by D1.c4, D1.c16, D1.c5, D1.c13, D1.c6, D1.c7, D1.c15, D1.c8) as c11,
    sum(D1.c12) over (partition by D1.c4, D1.c16, D1.c5, D1.c13, D1.c6, D1.c7, D1.c15, D1.c8) as c12,
    D1.c13 as c13,
    D1.c14 as c14,
    D1.c15 as c15,
    D1.c16 as c16
    from
    (select max(T56699.TEST_SCORE_NUMBER) as c1,
    count(T56699.TEST_SCORE_NUMBER) as c2,
    sum(T56699.TEST_SCORE_NUMBER) as c3,
    T33435.SCHOOL_YEAR as c4,
    T34232.TEST_SEASON_NAME as c5,
    T52429.TEST_SUBJECT_NAME as c6,
    T52429.TEST_LEVEL_NAME as c7,
    T59709.SCHOOL_NAME as c8,
    count(T36922.STDNT_STNDRD_TEST_KEY) as c12,
    T36922.STDNT_STNDRD_TEST_KEY as c13,
    T56699.TEST_SCORE_NUMBER as c14,
    T56693.TEST_SCORE_TYPE_NAME as c15,
    T36922.STUDENTS_KEY as c16
    from
    SCHOOLS T59709,
    TEST_DEFINITIONS T58733,
    TEST_SCORE_TYPES T56693,
    RPT_TEST_DEFINITIONS T52429,
    TEST_YEAR_SEASONS T34232,
    REPORTING_SCHOOL_YEARS T33435,
    TESTS T34149,
    DETAIL_TEST_SCORES T33341,
    STUDENT_STANDARD_TEST T36922,
    TEST_SCORES T56699
    where ( T33341.TEST_SCORE_TYPES_KEY = T56693.TEST_SCORE_TYPES_KEY and T36922.ADMIN_SCHOOLS_KEY = T59709.SCHOOLS_KEY and T34232.TEST_YEAR_SEASONS_KEY = T36922.TEST_YEAR_SEASONS_KEY and T33435.REPORTING_SCHOOL_YEARS_KEY = T36922.REPORTING_SCHOOL_YEARS_KEY and T34149.TESTS_KEY = T36922.TESTS_KEY and T36922.TEST_DEFINITIONS_KEY = T58733.TEST_DEFINITIONS_KEY and T33341.STDNT_STNDRD_TEST_KEY = T36922.STDNT_STNDRD_TEST_KEY and T33341.TEST_SCORES_KEY = T56699.TEST_SCORES_KEY and T33435.SCHOOL_YEAR = '200102' and T34149.TEST_ID = 'SOL' and T34232.TEST_SEASON_NAME = 'SPRING' and T36922.RPT_TEST_DEFINITIONS_KEY = T52429.RPT_TEST_DEFINITIONS_KEY and T52429.TEST_LEVEL_NAME = 'GRADE 5' and T56693.TEST_SCORE_TYPE_NAME = 'RAW SCORE' and T58733.PARENT_TEST_SUBJECT_NAME = 'MATHEMATICS' and T59709.SCHOOL_NAME = 'GLASGOW MIDDLE' and T56699.TEST_SCORE_NUMBER < 900 )
    group by T33435.SCHOOL_YEAR, T34232.TEST_SEASON_NAME, T36922.STDNT_STNDRD_TEST_KEY, T36922.STUDENTS_KEY, T52429.TEST_SUBJECT_NAME, T52429.TEST_LEVEL_NAME, T56693.TEST_SCORE_TYPE_NAME, T56699.TEST_SCORE_NUMBER, T59709.SCHOOL_NAME
    ) D1
    ) D1

  • How to sum only the positive numbers in a Pivot table when using Power Pivot

    Hi, I have this schema:
    …and this Pivot:
    How do I get this result from PowerPivot.
    If I only use normal Excel Pivot I could use Calculated Field and get the wanted result in a snatch.
    But I guess the problem with using PowerPivot in this scenario is a context or/and a aggregation problem?
    Here is the formula I try to use (I have also tried the FILTER function but couldn’t get it right):
    TRUE DEMAND (Forecast- Stock>0) =
    CALCULATE([TOTAL DIFF (FORECAST-STOCK)],
    [TOTAL DIFF (FORECAST-STOCK)]>0)
    Here is my ExcelFile:
    https://onedrive.live.com/redir?resid=B7906DD091ACC085!357&authkey=!AJN_r_1NCP4thrE&ithint=file%2cxlsx
    Any suggestions?
    Best Regards
    Tommy

    Hi Tommy,
    sorry, a few words are not enough.
    This post does explains it in detail:
    http://sqlblog.com/blogs/marco_russo/archive/2010/01/03/how-calculate-works-in-dax.aspx
    Imke

  • How to place the page items horizontal in pivot table in OBIEE

    Hi experts
    In pivot table i have two pages items. And i want to place them horizaontaly. So how can i achieve this.
    for Ex: I have placed my two columns in page section of pivot table: Year,city.
    then i need as ;
    Year City
    where year is one dropdown list and city is another drop down list.
    Thanks in advance
    Regards
    Sunil

    Hi,
    We can seperate the page items using 'Start New Page Drop Down', but the item will be displayed in the next line.
    I think you would like to show them side by side i.e, horizontally..
    If it is, i think it is not possible as of OBIEE 10.1.3.3.. not sure about 10.1.3.4..
    Please let me know if my assumption is wrong.. I will be very happy if anyone corrects me..:)
    -Vency

  • Using the Current Function in a repeating table with cascading drop-downs

    I have a Repeating Table where a customer can choose the values for three cascading drop-downs. I then want the member to start a new entry with the same cascading drop-downs but with different results based on their most current input not
    based on all their input throughout the form.  I also do not want the current input to affect previous inputs replacing what was already entered.  
    Please assist.
    -Ben
     

    Hi,
    Based on your description, you don't want to meet the following issues:
    The first row returns back all the data from the list up to the value selected.
    Any new item added, replaces the value in the other items.
    Here is an article about InfoPath Repeating Table Lookup control on SharePoint List, refer to it:
    http://www.sumitrawat.net/2009/10/infopath-repeating-table-lookup-control.html
    Besides, here is a similar post, you can use as a reference:
    https://social.msdn.microsoft.com/Forums/office/en-US/43253974-990d-4307-bf54-cc615618362a/issue-with-cascading-dropdown-in-a-repeating-table
    Best Regards,
    Lisa Chen
    Lisa Chen
    TechNet Community Support

  • Use of LinRegSlope in Pivot Table

    Hi, I am new to OLAP and am having a hard time using the LinRegSlope function on a pivot table. I have a pivot table which pulls data from a server and has "store names" (rows) and "dates" (columns) as the dimensions. i.e.
    [State].[City].[Store] and [year].[month].[date]. The measure being displayed is Revenue.
    I would like to calculate the slope of the "Revenues", such that I could tell whether the revenue on a specifc store is going up or down through a deternimed period of time - only the period being displayed on the table (e.g. 10/10/2014
    through 10/25/2014). I want the slope to appear as a column within the pivot table, and I want it to adjust to the number of stores and dates being displayed at the time (i.e. in the example above the slope should be calculated over a 16 day period because
    there are 16 dates being displayed).
    Any help on the syntax of the function would be greatly appreciated.
    -Jose

    Hi Josemp,
    According to your description, you want to calculate the sales slope from 10/10/2014 to 10/25/2014. Right?
    In Analysis Services, we can use LinRegSlope() function, specify Sales as Y axis value, Date as X axis value. Please refer to the query below:
    WITH
          MEMBER Measures.[Slope] AS
           LINREGSLOPE(LASTPERIODS(16) AS
          [TimeSet],[Measures].[Internet Sales Amount] , RANK([Date].[Fiscal].CurrentMember, [TimeSet]))
    SELECT
          {[Measures].[Slope]} ON COLUMNS,
           {[Date].[Date].&[20051010]:[Date].[Date].&[20051025]}ON ROWS
    FROM
          [Adventure Works]
    If you have any question, please feel free to ask.
    Simon Hou
    TechNet Community Support

  • What is differenence b/w table & pivot table?

    hai........
    what is differenence b/w table & pivot table?

    1. In Pivot table View you can view the data in cross tab fashion where as in Table View you can not....
    (CrossTab means you can create a report where you can see (for example) Sales Values with Region in rows section and Year in Columns Section)
    ------------Year----------------Year-------------Year
    ------------2001---------------2002-------------2003
    East------ 200--------------500-----------------100
    West-----300---------------600----------------5000
    South----100---------------4000--------------30002. In TableView you can use the WriteBack functionality but in Pivot Table view you can not.....
    3. In Pivot table you must have at least one measure in the measures section other wise it won't display the results, But in table view there is no such a constraint....
    HTH

  • Why doesn't PIVOT clause work with COLLECT aggregate function in 11g ?

    Hello all !
    I am really puzzled as to what is considered an aggregate function in the context of the PIVOT clause in 11g.
    I have been toying with quite a few things related to collections lately and this arose as an aside :
    CREATE TABLE TEST_COLL
       NODE_ID    VARCHAR2(15 CHAR) NOT NULL,
       NODE_VALUE VARCHAR2(45 CHAR) NOT NULL,
       NODE_LEVEL NUMBER(1)         NOT NULL
    CREATE OR REPLACE TYPE TREE_NODE AS OBJECT
       NODE_KEY  VARCHAR2( 15 CHAR),
       NODE_NAME VARCHAR2(127 CHAR)
    CREATE OR REPLACE TYPE TREE_NODES AS TABLE OF TREE_NODE NOT NULL;At this stage I am sure we all agree that the query
    SELECT NODE_LEVEL,
           CAST(COLLECT(TREE_NODE(NODE_ID, NODE_VALUE)) AS TREE_NODES) AS NODES
      FROM TEST_COLL
    GROUP BY NODE_LEVEL;is perfectly valid as the COLLECT function is an aggregate function according to the [Official Documentation|http://docs.oracle.com/cd/E11882_01/server.112/e10592/functions031.htm#i1271564]
    But then, one of the following two queries should work
    SELECT CAST(REGION_NODES     AS TREE_NODES) AS REGIONS,
           CAST(DEPARTMENT_NODES AS TREE_NODES) AS DEPARTMENTS,
           CAST(AREA_NODES       AS TREE_NODES) AS AREAS,
           CAST(CENTRE_NODES     AS TREE_NODES) AS CENTRES
      FROM (SELECT NODE_LEVEL, TREE_NODE(NODE_ID, NODE_VALUE) AS NODE
              FROM TREE_COLL
    PIVOT (COLLECT(NODE) FOR NODE_LEVEL IN (1 AS REGION_NODES,
                                             2 AS DEPARTMENT_NODES,
                                             3 AS AREA_NODES,
                                             4 AS CENTRE_NODES
    or (better)
    SELECT REGION_NODES     AS REGIONS,
           DEPARTMENT_NODES AS DEPARTMENTS,
           AREA_NODES       AS AREAS,
           CENTRE_NODES     AS CENTRES
      FROM (SELECT NODE_LEVEL, TREE_NODE(NODE_ID, NODE_VALUE) AS NODE
              FROM TREE_COLL
    PIVOT (CAST(COLLECT(NODE) AS TREE_NODES) FOR NODE_LEVEL IN (1 AS REGION_NODES,
                                                                 2 AS DEPARTMENT_NODES,
                                                                 3 AS AREA_NODES,
                                                                 4 AS CENTRE_NODES
           );yet, both fail with
    ORA-56902: expect aggregate function inside pivot operationInvestigating further, I found the same behaviour when using XMLAGG as the aggregate function in the PIVOT clause.
    Is this normal ? And if it is, is there any other way to achieve the result I was anticipating ?
    My version is
    SQL> SELECT BANNER FROM V$VERSION;
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
    PL/SQL Release 11.2.0.3.0 - Production
    CORE    11.2.0.3.0      Production
    TNS for 64-bit Windows: Version 11.2.0.3.0 - Production
    NLSRTL Version 11.2.0.3.0 - ProductionThanks in advance
    Best Regards
    Philip

    Most likely a bug. But you can bypass it by using any other aggregate making sure group consists of a single row and apply collect to a pivoted value. Yes, the cost is double aggregation. And also there is another cost - you would need to create MAP member function otherwise aggreations like MAX/MIN, etc. will not work:
    CREATE OR REPLACE TYPE TREE_NODE AS OBJECT
       NODE_KEY  VARCHAR2( 15 CHAR),
       NODE_NAME VARCHAR2(127 CHAR),
       map member function f return varchar2
    Type created.
    CREATE OR REPLACE TYPE BODY TREE_NODE AS
      map member function f return varchar2 is
      begin
         return NODE_NAME;
      end f;
    end;
    Type body created.
    CREATE OR REPLACE TYPE TREE_NODES AS TABLE OF TREE_NODE NOT NULL
    Type created.
    SQL> select  *
      2    from  test_coll
      3  /
    NODE_ID NODE_VALUE NODE_LEVEL
    1       A                   1
    2       B                   2
    3       C                   3
    4       D                   4
    5       E                   1
    6       F                   2
    7       G                   3
    8       H                   4
    8 rows selected.
    SQL> Now:
    SELECT CAST(COLLECT(REGION_NODES)     AS TREE_NODES) AS REGIONS,
           CAST(COLLECT(DEPARTMENT_NODES) AS TREE_NODES) AS DEPARTMENTS,
           CAST(COLLECT(AREA_NODES)       AS TREE_NODES) AS AREAS,
           CAST(COLLECT(CENTRE_NODES)     AS TREE_NODES) AS CENTRES
      FROM (
            SELECT  ROWID RID,
                    NODE_LEVEL,
                    TREE_NODE(NODE_ID, NODE_VALUE) AS NODE
              FROM  TEST_COLL
    PIVOT (MAX(NODE) FOR NODE_LEVEL IN (
                                         1 AS REGION_NODES,
                                         2 AS DEPARTMENT_NODES,
                                         3 AS AREA_NODES,
                                         4 AS CENTRE_NODES
    REGIONS(NODE_KEY, NODE_NAME)                         DEPARTMENTS(NODE_KEY, NODE_NAME)                     AREAS(NODE_KEY, NODE_NAME)                           CENTRES(NODE_KEY, NODE_NAME)
    TREE_NODES(TREE_NODE('1', 'A'), TREE_NODE('5', 'E')) TREE_NODES(TREE_NODE('6', 'F'), TREE_NODE('2', 'B')) TREE_NODES(TREE_NODE('7', 'G'), TREE_NODE('3', 'C')) TREE_NODES(TREE_NODE('8', 'H'), TREE_NODE('4', 'D'))
    SQL> SY.

  • Pivot type query without aggregate function. Transposing

    Hi experts,
    Oracle 11g.
    I have a table (see code example to reproduce), that has a date, a grouping, and the count of that grouping (determined in another query). I need a pivot type query, but, without the aggregate functions. This is just for a report display. I can not seem to figure this one out. Thanks for your help.
    CREATE TABLE temp_task
    AS
       SELECT TO_DATE ('15-NOV-2012') validation_date,
              'GROUP 1' AS group_number,
              42 AS monthly_count
         FROM DUAL
       UNION ALL
       SELECT TO_DATE ('14-DEC-2012') validation_date,
              'GROUP 1' AS group_number,
              33 AS monthly_count
         FROM DUAL
       UNION ALL
       SELECT TO_DATE ('15-NOV-2012') validation_date,
              'GROUP 2' AS group_number,
              10 AS monthly_count
         FROM DUAL
       UNION ALL
       SELECT TO_DATE ('14-DEC-2012') validation_date,
              'GROUP 2' AS group_number,
              32 AS monthly_count
         FROM DUAL
       UNION ALL
       SELECT TO_DATE ('15-NOV-2012') validation_date,
              'GROUP 3' AS group_number,
              7 AS monthly_count
         FROM DUAL
       UNION ALL
       SELECT TO_DATE ('14-DEC-2012') validation_date,
              'GROUP 3' AS group_number,
              9 AS monthly_count
         FROM DUAL;Using only SQL I need to return the following:
    VALIDATION_DATE | GROUP 1 | GROUP 2 | GROUP 3
    11/15/2012 | 42 | 10 | 7
    12/14/2012 | 33 | 32 | 9

    Hi
    You always need to use an aggregate function while pivoting.
    Even if you don't really need any aggregation, that is, when what you see in the table is what you'll get in the result set, you still have to use an aggregate function. If there will only be one value contrinuting to each cell, then you can use MIN or MAX. It won't matter which; since there's only 1 value, that value will be the highest of the 1, and it will also be the lowest. For NUMBER columns, you could also use SUM or AVG.
    SELECT       *
    FROM       temp_task
    PIVOT       ( MIN (monthly_count)
             FOR group_number IN ( 'GROUP 1'
                                 , 'GROUP 2'
                        , 'GROUP 3'
    ORDER BY  validation_date
    ; Output:
    VALIDATION_  'GROUP 1'  'GROUP 2'  'GROUP 3'
    15-Nov-2012         42         10          7
    14-Dec-2012         33         32          9It sounds like you're doing real aggregation someplace, to get monthly_count. Maybe it would be simpler and more efficient to do the pivoting at that point. What is the big picture here? Post some sample data as it is before you compute monthly_count, and the results you want from that data (if different from what you've already posted), and then let's see if we can't aggregte it and pivot it at the same time.

  • How to make a layer from the ADF pivot table invisible?

    Hi all,
    ADF pivot table is a useful component which can be used to provide table data rendering. However, I have not found any method to hide one layer from the row edge (or column edge) of the pivot table.
    For example, please have a look on this demo: [http://jdevadf.oracle.com/adf-richclient-demo/faces/components/pivotTable.jspx]
    There are two layers in the row edge of this pivot table, one is Time, one is Product. For product, there are two categories, one is Tents, one is Canoes.
    Is that possible to make the Product layer invisible from user, while still keeping the two rows of product data for that year showing up? how to do it?
    The problem is that pivot table relies on the product layer to separate the two rows of product data, and if I remove the product layer, only the second row of product data for each year can be shown up.
    Please advise how I can make the Product layer invisible.
    Thanks
    Richard
    Edited by: user12847742 on Oct 6, 2010 12:58 AM
    Edited by: user12847742 on Oct 6, 2010 1:04 AM
    Edited by: user12847742 on Oct 6, 2010 1:10 AM

    Hi, Yiannis,
    Thanks for the clarification.
    First, for clarity, I'd like to point out that you and Richard are inquiring about different functionality. Richard wanted to hide a layer that is logically present on the edge, so that there are still separate rows for Tents and Canoes, but without row headers indicating which row is which. As I noted previously, this is currently unsupported.
    By contrast, you're asking about truly removing a layer from the edge. For rowset DataControls, this can be done using the CubicEditor interface. Given the following PivotTable:
    <dvt:pivotTable id="pivotTable1" value="#{bindings.Record.pivotTableModel}"/>the CubicEditor can be retrieved by calling:
    DCBindingContainer bindingContainer = (DCBindingContainer)ADFContext.getCurrent().getRequestScope().get("bindings");
    CubicBinding cubicBinding = (CubicBinding)bindingContainer.findCtrlBinding("Record");
    CubicEditor cubicEditor = cubicBinding.getCubicEditor();You can then add a layer:
    LayerDefinition layerDefinition = new LayerDefinition("Product");
    cubicEditor.addLayer(DataDirector.ROW_EDGE, 1, layerDefinition);and remove a layer:
    cubicEditor.removeLayer(DataDirector.COLUMN_EDGE, 0);At the end, you'll need to PPR the Pivot Table.
    Hope that helps.
    Jim

  • Increasing the width of Pivot table Columns

    Hi Gurus,
    Small pivot table --> ( ie having less no of columns which generally can be seen in a single page without scrolling to the right)
    If i have a small pivot table , then in the column properties through additional formatting options i can increase the width of an individual column.
    However if the pivot table is Big,I am not able to increase the width of the individual column .
    I tried setting width in the additional formatting options in the Content Properties( just above Rows and below Section there is a small grey box containing finger).
    Now the Content Properties indeed increases the width of the column, but it also increase the width of the whole Pivot Table.
    See...If i have a fixed number of columns in a PIVOT Table that do not change with prompt, then this solution work fine...
    but the problem comes when the no of columns in pivot Table reduces based on the prompt selected.
    In this case the less no of columns tries to occupy the whole width set in the content properties.
    In short, with Content Properties the width of the PIVOT Table becomes fixed, irrespective of the no of columns coming.
    Also after setting content properties, I am not able to print the report to PDF.
    So the Question is... Can we increase the width of a Big Pivot Table whose no of columns keeps on changing based on the prompt....
    Big pivot table -->
    (ie table having no of columns which exceeds a single window frame and have to scroll to right to see the rest of the columns)
    I hope i have not made things messy...
    Thanks
    Ashish

    Ashish,
    Yes, you can set a fixed size for these. I'm sure you are fixing these because of PDF issue which might be irregular in sizes. Just play arnd with Custom CSS options.

Maybe you are looking for

  • I cannot open websites that I normally open everyday. I have Firefox 5.0 When I try to open something, it says The connection has timed out

    Can someone please help? It was working fine. Now I can open some things, but not my regular sites that I have on my desktop. It just tries to connect, then says, The connection has timed out

  • Function Module to edit ABAP coding

    Hi Gurus, Can anyone tell me if there is any standard function module to go into the code and change some code dynamically in abap Editor. There is some text needs to be changed in source code, which occurs huge number of times. Manually to do it is

  • Idoc to flatfile FCC issue

    Hello everybody, i am implementing an idoc-flatfile scenario (PI 7.1). It works to write an xml file into directory, as soon as I use FCC in order to generate txt-file, no file is written, and sxmb_moni shows an acknowledgement with system error. In

  • Name of Computer changed during Migration.

    I used Migration Assistant to Merge my data, settings, and files from my Macbook to my iMac, but every where I see the name of my computer it says "Trey's MacBook" is there a way to change this?

  • Contact does not show up as imessage

    Hey I got an iphone 6 with ios 8.1.3 but never had any problems with imessage. It always works fine. My colleague, who has an iphone 5s (software i'm assuming up to date, both work for a tech company), cannot seem to send me imessages and vice versa.