Chart Query

Hi guys,
I need to display the percentage of the total income of the company that each agent has made on a pie chart:
I used this query, but the problem is that when I run the query on Sql workshop it works probably. but on the chart it does not show up the exact values
select null link, agent label, round ( (SUM(total_comm) * 100 / (select sum(total_comm) sum_val from incomes)),2)
PERCENTAGE from incomes group by agent
LABEL     PERCENTAGE
F_Mohammad     8.8
A_Firas     12.8
A_Elias     13.9
B_Tarek     19.84
Q_Ziad     4.7
S_Bashar     6.69
K_Jihad     11.92
M_Tshepo     6.64
M_Firas     .33
I_Aamir     14.38On the chart it is how these values :
F_Mohammad     3
A_Firas     3
A_Elias     6
B_Tarek     8
Q_Ziad     3
S_Bashar     1
K_Jihad     3
M_Tshepo     2
I_Aamir     3By the way, Perhaps someone can tell how can I put a table in the thread.
I hope my Question is clear.
Best Regards,
Fateh
Edited by: Fateh on Sep 3, 2011 3:00 AM

Fateh,
Try it this way:
SELECT NULL                                               link,
       agent                                              label,
       Round (( SUM(total_comm) * 100 / sub.sum_val ), 2) percentage
FROM   incomes,
       (SELECT SUM(total_comm) sum_val
        FROM   incomes) sub
GROUP  BY agent   Jeff

Similar Messages

  • Legend needs to display Prompt values / Remove filters from chart query

    Hi
    I have 2 questions for the same chart so I hope it's OK to add them in one post.
    Firstly I have created a chart & added three Select List filters which work fine, the query is below, problem is that when I change back to '-ALL-' I get no data, it has filtered out all records as no data matches the value of '-ALL-' does anyone know the code to get around this?
    My chart query;
    select null link, P_MONTH AS MONTH, SUM(CALLS) AS data
    from DATA.MAIN_DATA
    WHERE WAREHOUSE = :P1_WAREHOUSE
    AND ANS_UNANS = :P1_ANS_UNANS
    AND PRODUCT = :P1_PRODUCT
    GROUP BY P_MONTH
    As I will have several queries like the one above for different options on the same chart, I would like the Legend to show what the user has chosen each time the options are changed ie;
    Something like the bolded text in the query to display the chosen values in the legend;
    select null link, P_MONTH AS MONTH, SUM(CALLS) AS *'P1_WAREHOUSE' || 'P1_ANS_UNANS' || 'P1_PRODUCT'*
    from DATA.MAIN_DATA
    WHERE WAREHOUSE = :P1_WAREHOUSE
    AND ANS_UNANS = :P1_ANS_UNANS
    AND PRODUCT = :P1_PRODUCT
    GROUP BY P_MONTH
    Any ideas/suggests?

    Woof777 wrote:
    Any ideas/suggests?Try the APEX forum ;)

  • Unable to edit wizard created SVG chart query

    Hi,
    I have a problem with an SVG chart that one of the HTML DB wizards created.
    On the generated page the wizard created a selection list item named P30_SHOW.
    This item allows to choose a table column based on which an SVG pie chart is generated.
    The automatically generated chart query is:
    select 'f?p=106:26:&SESSION.:::RP,26:P26_CHART_FILTER,P26_VALUE:'||:P30_SHOW||','||"&P30_SHOW.",
    "&P30_SHOW.", count(*)
    from "TESTTABLE"
    group by 'f?p=106:26:&SESSION.:::RP,26:P26_CHART_FILTER,P26_VALUE:'||:P30_SHOW||','||"&P30_SHOW.",
    "&P30_SHOW."
    The page with selection list and chart worked fine at first.
    But then, when I edited the chart's width on the respective 'SVG Chart Attributes' tab and pressed
    the 'Apply Changes' button I got the following error:
    'Query cannot be parsed, please check the syntax of your query. (ORA-01741: illegal zero-length identifier)'
    I only changed the chart's width, I did not touch the chart's query at all.
    My theory is that HTML DB tries to validate the correctness of the chart's query.
    However, the query references a session variable (P30_SHOW) that is
    not defined in my development session. Consequently, the query is not valid in the
    development context and is refused by HTML DB.
    Now I have two questions:
    1. Is my analysis correct, or are there different reasons for the error I do encounter?
    2. How can I get around the problem? I'd like to use the automatically generated charts,
    but also want to be able to edit them.
    Thanks in advance for helpful comments.
    Regards Holger

    Scott,
    I imported the application using the import/install process. A new application ID was created but was not changed in the chart query. The link was generated by the application wizard. The chart query link is below:
    select 'f?p=103:2:&SESSION.:::RP,2:P2_CHART_FILTER,P2_VALUE:'||:P6_SHOW||','||"&P6_SHOW.", "&P6_SHOW.", count(*)
    from "O_DATA_COLLECTION_POINTS"
    group by 'f?p=103:2:&SESSION.:::RP,2:P2_CHART_FILTER,P2_VALUE:'||:P6_SHOW||','||"&P6_SHOW.", "&P6_SHOW."
    The new application id is 101. It is impossible to modify this query because of message:
    "1 error has occurred
    Query cannot be parsed, please check the syntax of your query. (ORA-01741: illegal zero-length identifier"
    This happens even if nothing is changed in the query but just the apply changes button is pressed.
    I had a similar problem with the breadcrumbs menu. The link was also pointing to the old application id 103 instead of the new application id 101. The way I got round that was to delete the breadcrumb template and create a new one. I then had to go through all the pages that referenced that and reset the breadcrumbs menu template in the region definition.
    Thanks Arjen

  • Chart Query and Failed to parse SQL query

    Hi,
    first of all, this is not a question. It is a reminder for me and maybe for someone with the same problem.
    I just fell over this for the 123124 time.
    I have a 3D Chart Query
    select sum(order_ok) value,
          count(*) maximum_value
    from      v_dialer_campaign
    where campaign_uuid = :P300_CAMPAIGN_IDSaving fails with
    "1 error has occurred Failed to parse SQL query!" ...
    Saving the query without validation works, but does not show any result in the chart.
    v_dialer_campaign is a view selecting from a view in a mssql db over database link and HS.
    running the select in sqlplus or toad works.
    Without any trace on freetds/unixodb/hs side, i would have not found the following line:
    [FreeTDS][SQL Server]The data types nvarchar and text are incompatible in the equal to operator.[FreeTDS][SQL Server]Statement(s) could not be prepared.
    Solution:
    with q as (select :P300_CAMPAIGN_ID val from dual)
    select     sum(order_ok) value,
         count(*) maximum_value
    from     v_dialer_campaign
    where     campaign_uuid in ( select val from q)Maybe the error output when validating the query should be included in the APEX error message.
    Same solution applies for dynamic LOV's reading from HS using a where clause.

    I tried your first query on Apex 3.2 and it created a nice dial chart.
    Is there any ORA-xxxxx error along with the "failed to parse SQL query" message? Did you double check column & table name spelling?
    P.S. The second query is invalid (a superfluous comma after the second column).

  • Chart Query problem

    Hi all ,
    I am a newbie to Oracle apex and have stuck in an issue . I am using this query for my Chart Source
    select NULL link, count() Count VALUE , to_char((TRUNC(ORDER_DATE)),'Month') "Month"*
    from  "HR"."OEHR_ORDERS"
    group by to_char((TRUNC(ORDER_DATE)),'Month')
    order by 1 desc
    but it gives this error when i click next
    1 error has occurred
    Failed to parse SQL query!
    select NULL link, count() Count VALUE , to_char((TRUNC(ORDER_DATE)),'Month') "Month" from "HR"."OEHR_ORDERS" group by to_char((TRUNC(ORDER_DATE)),'Month') order by 1 desc*
    Certain queries can only be executed when running your application, if your query appears syntactically correct, you can save your query without validation (see options below query source).
    what should i do and what am i doing wrong ? as this query gives the correct result if i run it in SQL window
    thanks for the help in advance

    In your first query, you gave the count(*) column two names COUNT and Value. That I think was your only mistake.
    The column ordering might not matter if you only have one value column, but if you want a single chart query to represent more than one line, then the ordering matters.
    In my application I use an Apex item to hold the entire query as text, including v(...) bindings, and displays 1 to 50 lines, dynamically depending on the number of value columns. The names of the lines are derived from the column names.
    /kenny

  • How to use Item value in chart query

    Hi Folks,
    I am looking to use calander item value in sql query used to populate flash chart. I tried with following query where P2_DATE1 is the calander item name. This says no data found. I am not sure if I am missing some thing with BUTTON settings which I am using to put data into chart.
    Select null "link",to_date(entry_date,'dd-mon-yy hh:mi:ss') "Time in GMT", to_number(load_avg_5,'99.99') "Load Avg 5 Min" from oracle_ocm.top_load_avg --where trunc(entry_date)=:P2_DATE1
    I am new to APEX
    Please help

    Here are few things for you to try:
    Hardcode the value and see if it works. "where trunc(entry_date) = to_date('01-May-2010', 'dd-Mon-yyyy')". If it works, then click Session link at the bottom of the page, and check the value of the item P2_DATE1. If null, then you have a problem. If not null, please ensure that you use TO_DATE function as shown above with proper format mask.
    Good luck.
    Ravi A

  • Stacked Bar Chart Query

    Hello everyone,
    I need some help on a query for a Stacked Bar Chart.
    I copied the following query from the "How To" Pages for a Stacked Bar (HTML DB 2 Day Developer) and adjusted it according to my tables:
    SELECT NULL l,
    sales_month,
    revenue
    FROM (
    SELECT TO_CHAR(o.order_timestamp,'Mon YYYY') sales_month,
    SUM(oi.quantity * oi.unit_price) revenue,
    TO_DATE(to_char(o.order_timestamp,'Mon YYYY'),'Mon YYYY') sales_month_order
    FROM DEMO_PRODUCT_INFO p,
    DEMO_ORDER_ITEMS oi,
    DEMO_ORDERS o
    WHERE o.order_timestamp <= (trunc(sysdate,'MON')-1)
    AND o.order_timestamp > (trunc(sysdate-365,'MON'))
    AND o.order_id = oi.order_id
    AND oi.product_id = p.product_id
    AND p.category = 'Phones'
    GROUP BY TO_CHAR(o.order_timestamp,'Mon YYYY')
    ORDER BY sales_month_order
    The problem now that I have is, that the results are not always correct.
    That means, that the numbers for every month that has 31 days is incorrect.
    I created a chart for 2005 and the numbers for Jan, March, May, July and so on are wrong. I found out that they always include numbers from the next (first) day of the next month, that means that the January number contains the numbers from the 1st of February, that March number contains the numbers of the 1st of April and so on. The only difference of my query is that I did not use a timestamp but rather a date. Can someone tell me what to do to solve the problem without changing the column to timestamp? I assume it has something to do with rounding up or "truncating" the date!?
    I appreciate your help!!

    Is there nobody out there, how might give me a hint ?? :-(

  • Pie Chart / Query : Top 3 and Remainder

    Hi
    I am trying to develop a template, which shows various exception information to the end user. There are approximately 20 exception scenarios which are analysed each night and data stored in the cube. This information is then related back to the end user via a simple web template.
    I can show that data in a table nicely.
    I have created an additional query with a "Top 3" condition applied, which results in the 3 exceptions that contribute the mos to the total being displayed. This query can then be used as the source for a pie chart, so the user can see graphically which are the most important exceptions to address.
    I have now been asked to include a "remainder" item in that pie chart, or not have the pie chart add up to 100%. What the user wants to see, is what the top 3 exceptions were, and what all the other exceptions added up to, essentially the difference between 100% and the sum of the contribution (%) of the top 3.
    I can write a query which displays the top 3, and include in that a result row which shows the sum of the percentages. So, for example, it will display the 3 and the total will be 87%, meaning the remaining errors contributed 13%, but how would I get this as an additional row in the query?
    Alternately, is it possible to have a pie chart that doesn't add up to 100%. A pie chart that is incomplete in essence?
    Any advice would be appreciated.
    Cheers,
    Andrew

    Hi Andrew,
    To show the value as a percentage and not have the total be 100%, you need to calculate the value in the query. Create a key figure to calculate the percentage and use a condition to only show the top 3. Conditions wont effect the totals or percentages so the total percentage won't add up to 100.
    I don't think it's possible to show a 'other' value with the remainder.
    Kind regards,
    Alex

  • Line Chart query...having issues with finding the right SQL...tough query

    This initaial entry was much longer and confusing.
    I'm looking to make ar running total based using time periods...see the link in the last post to get to the demo.apex.com area.
    Rob
    Edited by: bostonmacosx on Feb 14, 2013 1:33 PM

    bostonmacosx wrote:
    Hello there. So I hope I can explain this sufficiently:
    OUT OF THE WAY: 11g 4.1.1
    I'm going to simplify my data so that it is clear what I'm looking to do.
    I want to have a line chart grouped by date. Let's say monthly...this is easy to do if you are dealing with one specific date and some value you can build the series against with case statements. I've done that a million times.
    The columns of data I'm dealing with are as follows:
    CREATE_DT(create date)
    RETIRE_DT(retire date)
    MACHINE_TYPE(type of machine)
    So lets say I want to see a line chart where each line(data point) is a MACHINE_TYPE and each bin is a month. That month should be any machine with a CREATE_DT below then end of the month and a RETIRE_DT which is either Greater then the end of the month or is NULL(ala hasn't been retired yet).
    In the query for a chart which is
    SELECT LINK,LABEL,CASE()"",CASE()"",CASE()"" from TABLE GROUP BY ROLLUP(VALUE)I guess I'm not seeing how to be able to put these values together so that it walks month by month and figures out the values and puts them in the correct "bin" of time along the X axis of the chart.
    I hope I'm being semi clear as it is hard to explain this scenario. Nope. Clear as mud.
    If time is plotted against the X axis, what measure is plotted on the Y?
    =============
    on another note I built this table from the data:
    01-JAN-12     01-FEB-12     01-MAR-12     01-APR-12     01-MAY-12     01-JUN-12     01-JUL-12     01-AUG-12     01-SEP-12     01-OCT-12     01-NOV-12     01-DEC-12     01-JAN-13     ENVOS
    59     59     59     59     59     59     59     59     59     59     59     60     60      Alias
    12     26     26     26     26     26     26     26     26     26     26     26     26      Blade
    9     9     9     9     9     9     9     9     9     9     9     9     9      DataMvrUsing the function:
    create or replace FUNCTION ACTIVE_SYSTEMS
    RETURN VARCHAR2
    is
    var1 VARCHAR2(4000):= '';
    start_date DATE:= to_Date('05-JAN-2012','DD-MON-YYYY');
    end_date DATE:= to_Date('08-JAN-2013','DD-MON-YYYY');
    new_start_date DATE;
    BEGIN
    new_start_date:=trunc(start_date,'MONTH');
    var1 := q'!SELECT !';
    while(new_start_date<end_date)
    LOOP
    var1 := var1 || q'! count(case when create_dt<'!'||to_char(new_start_date,'DD-MON-YY')||q'!' and (retire_dt IS NULL or retire_dt>'!'||to_char(new_start_date,'DD-MON-YY')||q'!') then 1 end) "!' ||to_char(new_start_date,'DD-MON-YY')||q'!",!';
    new_start_date:= add_months(new_start_date,1);
    END LOOP;
    var1 := var1 || q'! CMS_NODE_OS.OS_TYPE||' '||node_env as envos from CMS.CMS_NODE LEFT join CMS.CMS_NODE_OS on CMS.CMS_NODE.NODE_NAME=CMS.CMS_NODE_OS.NODE_NAME where retire_dt is NULL group by rollup(CMS_NODE_OS.OS_TYPE||' '||node_env)!';
    RETURN var1;
    END;
    Instead of inadequate attempts to explain this here with fragments of code that we can't do anything with because we don't possess the objects and data they're based on, show us something. Create the objects and some sample data in a workspace on apex.oracle.com and post guest developer credentials. Sketch the required chart or mock it up in a spreadsheet and upload it as an image or PDF so we can see what you're aiming for.

  • Please help with chart query

    Hello, i am trying to display a line chart, for some sales data.
    I want a line (series) for each product, X axis should be the years in the data
    (2007, 2008, 2009 there is no more data than these years)
    The plan is to eventually use a "Function Returning SQL Query" to get dynamic series.
    But i tried to hardcode 2 lines for 2 products first to try it out.
    I used this query in SQL Workshop > SQL Commands
    to view the data i want and it works correctly
    Query1:
    SELECT product.major_brand, timeperiod.year, SUM(sales_fact.euro_sales) AS sales
    FROM sales_fact
    INNER JOIN product ON sales_fact.product_id = product.product_id
    INNER JOIN timeperiod ON sales_fact.timeperiod_id = timeperiod.timeperiod_id
    GROUP BY product.major_brand, timeperiod.year
    ORDER BY product.major_brand, timeperiod.year ASCI have tried the following query for the chart but it will show 2 flat lines
    with the value 0 for each year.
    Query2:
    SELECT NULL
          ,timeperiod.year
          ,SUM(decode(product.major_brand, 'BELCINO', sales_fact.euro_sales, 0)) "BELCINO"
          ,SUM(decode(product.major_brand, 'BIORGANIC', sales_fact.euro_sales, 0)) "BIORGANIC"
    FROM sales_fact
    INNER JOIN product ON sales_fact.product_id = product.product_id
    INNER JOIN timeperiod ON sales_fact.timeperiod_id = timeperiod.timeperiod_id
    GROUP BY product.major_brand, timeperiod.yearThanks for reading,
    Any help is appreciated!
    Edited by: 908157 on 15-jan-2012 5:22
    Edited by: 908157 on 15-jan-2012 5:22

    Thanks Jeff for the quick response,
    I have looked at the examples, tried some things
    and found out that my GROUP BY was the problem.
    Apperantly i only have to GROUP BY on year and not also on product.
    I dont fully understand why yet,
    i guess the query gets parsed and translated to 2 queries, one for each line, that makes sense
    This is the query that worked for me:
    SELECT NULL
          ,t.year
          ,SUM(decode(p.major_brand, 'BELCINO', s.euro_sales, 0)) "BELCINO"
          ,SUM(decode(p.major_brand, 'BIORGANIC', s.euro_sales, 0)) "BIORGANIC"
    FROM sales_fact s, product p, timeperiod t
    WHERE s.product_id = p.product_id
    AND s.timeperiod_id = t.timeperiod_id
    GROUP BY t.year
    ORDER BY t.yearThanks again!

  • Charting Query: How to show detailed chart when clicked

    Hi , I have a flash chart that shows monthly summary values . When user clicks on a bar ( say for month of JAN), I want to show another chart based on data for JAN only. I am trying to figure out how to show my detail chart when user clicks on a summary bar.
    Can someone advise how can I pass value from parent chart to child chart?
    Thanks
    Aali
    Edited by: aali on 02-Feb-2010 00:30

    Hi Aali,
    Create 2 pages, one for summary the other for detailed (assuming P1 & P2). The query for your first chart needs to link to the second including a month value. It might look something like this:
    select 'f?p=&APP_ID.:2:'||:app_session||'::::P2_MONTH:'||MONTH||':' link, MONTH  label, SUM(SALES) value1
    from TBL_DETAILS
    group by MONTH
    -- :2: is the page you're linking to (detailed chart)
    -- P2_MONTH should be a hidden item on that page to store the month value
    -- MONTH is the value to be passed...this could be some substr(date_col, 4,6) or somethingCreate your Hidden P2_MONTH item making sure it is NOT Hidden and Protected. Page 2 query something like:
    select null link, DAY label, SUM(SALES) value1, SUM(COSTS) value2, COUNT(STAFF) value3
    from TBL_DETAILS
    where MONTH = :P2_MONTH
    group by DAYI don't have info on your tables though so hopefully this is helps.
    Mike

  • Charting Query Total results in WAD

    Hello, I have a question regarding charting only the results in WAD. Currently, I have a % Lot Acceptance Calculated Key figure and in my Rows "Vendor" Upon executing, I get each individual Vendor counts which fall in the % Lot Acceptance bucket. I then retrieve the results, summed up view but when I chart this in WAD, I do not want any low level results but only the rolled up results. Any suggestions on what approach I should take? Should I possibly be pre-calculating the % Lot Acceptance in the Update rules and create a new field % Lot Acceptance which holds the "resulted" value? Should I utilize Virtual Characteristics/Key Figures? Thanks for your help in advance.

    Andy,
    Welcome to SDn ,
    whhat you could do is to remove all the drill downs so that the query result matches what you want in the chart and then save the same as a view , then attach the view to a chart data provider.
    Maybe posting it in the Business Explorer forum will be of more help...
    hope this helps...
    Arun
    Assign points if useful

  • SVG Chart Query 'Length'

    Hi,
    I cause the following error to be raised when trying to save (Apply Changes) the query for an SVG chart:
    ORA-20001: set_attribute error: ORA-01461: can bind a LONG value only for insert into a LONG column
    The query just got 'longer' which prompts the question:
    Is there an upper limit to the length (number of characters) of the query ?
    Thanks for all and any help,
    sinclair

    I cannot answer your direct question, but if your SELECT statement is hard-coded and not generated from PL/SQL, I can offer a possible work around. You could create a database VIEW using your SELECT statement and query the view in your SVG chart.
    Mike

  • Help for conditional formatting of a chart query!!!!!

    Dear Gurus,
    can Anyone give me a step by step for conditional formatting on the chart?
    I want my charts in my queries to be for example:
    green color when actual data <= version,
    Yellow if actual > version & 101%, red if actual >=101%.
    Thank You very much for sharing your Knowledge.

    Hi Des,
    You can achieve this through exceptional reporting. Choose your query & execute the report. click on the 'Exceptions & Conditions' button. create the exception you wish to have by choosing version & your key figure, in your case. when you click 'Transfer' it automatically gets activated & you can be able to view the colors set by you.
    Revert back for any modifications.
    Manoj

  • Control Chart Query

    Dear Experts
    As part of SAP QM Implementation we are implementing control chart functionality to get graphical representation against measured values for pre-defined parameters. I am facing two issues mainly:
    1. When I try to calculate control limits (clicking calculator button) getting message "Control limits for track 1 could not be calculated". MICs has the upper limit and lower limit maintained which I can see in QAMV table for the inspection lots.
    2. In the attached control chart , I am getting Upper Limit, Lower Limit and the Valuated Result in graphical form, when I try to display the inspection date, for the characteristics against inspection lot, I get lost. System is showing some date 7/14/14 against all the characteristics which I am not sure how to achieve.
    Settings I made:
    Sampling type: Fixed sample
    Valuation mode: SPC inspection
    W/O inspection point
    Sample size: 5
    Chart type:115 Shewhart chart for X bar/USA
    MIC Settings:
    Quantitative / Lower / Upper Sp. Limit / Sampling Procedure / SPC Characteristics / Summerised Recording / Required Char.
    Inspection plan setting is:
    SPC criterion : 020 task list char/material
    Base qty : 1KG
    Control Chart Configurations:
    1. Control Chart Type -115
    a) Change Control Limit not checked
    b) Characteristics Type- Fixed Scope, Record measured values
    c) Reference Axis (x-axis) - Time of Creation ( Do I need to change here to "Object Number" or "Time Of Inspection" ?)
    Any input will be highly appreciated.
    Regards
    SK

    Hello,
    For Control limits your chart needs to closed. and offcourse for calculation u need to have more than one inspection lot. then system will calculate the same. UD is also required against lots.
    Regards

Maybe you are looking for