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 ?? :-(

Similar Messages

  • Jfreecharts- stacked bar chart query

    Hi all,
    I am using JfreeCharts for building an application which reports the usage metrics of two servers over a period of time.
    Each server does a number of operations which can be broadly grouped under 6 heads and these broad divisions are being used for reporting.
    When I use Stacked bar chart for creating the bar graph image, the order in which the bars get displayed is wierd. The dates start from 25th Feb to 28th Feb. Hence I am expecting the bars for the data from the dates 25th... 26th...27th and 28th; but the bars that come up are the 25th ... 26th... 28th and the 27th... Is there a group utility which can be used to order the grouping??? I am posting my code used for grouping the data.
    map = new KeyToGroupMap("G1");
    renderer = new GroupedStackedBarRenderer();
    for (int i = 0; i < (metricsList2[0].size()); i++)
    map.mapKeyToGroup(((XxccrCropsdbColourgrp)(metricsList2[0]).get(i)).getAttributeName1(), ((XxccrCropsdbColourgrp) (metricsList2[0]).get(i)).getAttributeName2());
    renderer.setSeriesToGroupMap(map);
    From the database the groups being sent are G1,G2,G3 and G4 which correspond to the 4 dates mentioned above.
    Help will be highly appreciated....
    Madhu

    The actual problem is when I am adding data to the map for the grouping , the data is getting jumbled up... The groups which are added to the map are not added in order.

  • SVG CHart error ORA-20001 with Stacked Bar Chart HTML DB 1.6.0.00.87

    Hi,
    during I put a How-To into execution (How To Create a Stacked Bar Chart) I'll get the following error code:
    SVG Chart error:ORA-20001:line_Chart error:ORA-20001:
    get_data error:ORA-20001:Parse error:ORA009
    (see http://www.oracle.com/technology/products/database/htmldb/howtos/index.html)
    This Situation occurs when i add a second series to the
    chart. The first series works fine. I've used the following SQL-Statement:
    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 = 'Audio' group by to_char(o.order_timestamp,'Mon YYYY') order by sales_month_order);
    Please help.
    Regards
    Detlev

    Well,
    I've just been struggling for a couple of hours with a cluster bar chart giving the same problem.
    The problem is definitely with "ORDER BY".
    I guess the graphing chart is taking the sql query as a string and then does some other manipulation on it which ends abnormally when you include the order by clause.
    I presume that if you embed the query in a
    SELECT * FROM (<actual query with order by>)
    it might mitigate the problem.
    Bye,
    Flavio

  • Stacked Bar Chart with Multiple Series Sort Question

    Hi,
    Apex version 4.1.1
    I have a stacked bar chart with three separate series, one showing customer effort, another showing project effort and the third showing other effort, summarized by calendar week. The x-axis of the chart is the calendar "week of" date, and the y-axis has a bar for each of the three series. Not every type of effort occurs every week.
    When AnyChart renders the chart, the order of entries on the x-axis seems to be dependent both on which series are present in a given week as well as the "week of" date. Weeks with all three series sort in order by calendar date, followed by weeks where just the 2nd & 3rd series are present, followed by weeks where just the 3rd series is present. See this [url http://tinypic.com/r/b9zdt/6] picture of the chart  noting the "week of" dates. Note that the months go Sep-Oct-Nov-Aug-Oct.
    Is there a way to force AnyChart to sort the x-axis in chronological order regardless of whether there is data for all three series for a given week? I have looked through the AnyChart XML reference but cannot find a way to do this.
    Incidentally, I can solve the sorting problem by combining all three series into a single query:
    select
      null as link,
      week_of as label,
      sum(customer_effort) as "Customer Effort",
      sum(project_effort) as "Project Effort",
      sum(other_effort) as "Training, Admin and Other Effort"
    from ...But if I do this, I cannot figure out how to have each bar on a given week link to a different detail page, e.g., if I click on a bar representing customer effort I want to link to one page, but if I click on a bar representing project effort, I want to link to a different page. I have had a look at the [url http://apex.oracle.com/pls/apex/f?p=36648:59:1570983160946101::NO:::] chart examples  posted on apex.oracle.com, but cannot figure out how to apply to multiple series in a single query.
    Thanks,
    Mike

    Thanks, Jeff. I did try this but for whatever reason it doesn't make a difference. I think it is because if there's no data for a given series for a certain week, there is no entry in the data set that is sent to AnyChart.
    I was able to get around the issue by "filling in" the missing weeks from each data series. To generate the list of "Week Of" dates for a given date range, I used this code:
    select
         trunc (each_day) as week_of,
         0 as effort
    from (
         select
              (to_date(:p920_start_date,:app_date_format) + 2 - to_char(to_date(:p920_start_date,:app_date_format),'D') - 1) + level each_day
         from dual
         connect by level <= to_date(:p920_end_date,:app_date_format) - to_date(:p920_start_date,:app_date_format) + 1
    where
         to_char (each_day, 'D') = '2'This creates an effort entry of 0 for each week within the date range; I use the Monday date of a week as the "Week Of" date. I then union this with my actual data and summarize by week and viola, I get the weeks in order. This also has the benefit of showing a week for which there are no entries in any of the three series.
    Thanks for taking a look at this.
    Mike

  • Stacked Bar chart mouseover options

    I am using the stacked bar chart. When mousing over the bars, it currently displays the totals on the very top of the bar. Is there a way to make the total display inside (or at the bottom) of the bar?

    Hi HCMJ,
    By default, the bar value will not overlapping each other in stacked bar chart, and we cannot increase or decrease the gap between the series in Reporting Services.
    Based on my research, I find a workaround can achieve your requirement, please refer to the steps below:
    Create a dataset with the query below (sample data):
    CREATE TABLE #temp(name nvarchar(50),time nvarchar(50),value int)
    INSERT INTO #temp VALUES     ('Invoiced','YEAR',100),('Invoiced','MONTH',200),('Budget','MONTH',300),('Budget','YEAR',600)
    SELECT * FROM  #temp
    Insert time field to Category Groups pane, and change the group name to “time”.
    Insert value field to Values pane, then change the value to like below:
    =min(Fields!value.Value,"time")
    Insert another field with the following expression to Values pane:
    =max(Fields!value.Value,"time")
    Change the type of chart from Stacked Bar Chart to Range Bar Chart.
    Right-click the Series field to change the Fill color to #9bff8c00 (DarkOrange with 155 Transparency) or any color with Transparency you like. Now we can get the following:
    Preview it and get the following result:
    If there are any other questions, please feel free to ask.
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • Stacked bar chart errors

    I am creating a stacked bar chart and put a max row count of 50, but the graph actually shows more than 50. After the 50 data points, all of the rest of the dates along the x axis are out of order. Is there another location i also need to enforce this max row count?

    Hi HCMJ,
    By default, the bar value will not overlapping each other in stacked bar chart, and we cannot increase or decrease the gap between the series in Reporting Services.
    Based on my research, I find a workaround can achieve your requirement, please refer to the steps below:
    Create a dataset with the query below (sample data):
    CREATE TABLE #temp(name nvarchar(50),time nvarchar(50),value int)
    INSERT INTO #temp VALUES     ('Invoiced','YEAR',100),('Invoiced','MONTH',200),('Budget','MONTH',300),('Budget','YEAR',600)
    SELECT * FROM  #temp
    Insert time field to Category Groups pane, and change the group name to “time”.
    Insert value field to Values pane, then change the value to like below:
    =min(Fields!value.Value,"time")
    Insert another field with the following expression to Values pane:
    =max(Fields!value.Value,"time")
    Change the type of chart from Stacked Bar Chart to Range Bar Chart.
    Right-click the Series field to change the Fill color to #9bff8c00 (DarkOrange with 155 Transparency) or any color with Transparency you like. Now we can get the following:
    Preview it and get the following result:
    If there are any other questions, please feel free to ask.
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • Stacked Bar Chart Question

    Hi, I am creating a stacked bar chart, and I am encountering 3 issues I hope you can help me with:
    1)  The chart has positive and negative values.  I have zero based centerline checked, but I do not see 0 on the Y axis.
    2)  The applet width is 900 pixels.  The chart can have a variable number of bars.  When it has a small number of bars, they fill the entire chart.  Is there a way to set the width to a fixed amount?
    3)  Is there a way to set a logical interval amount?  Currently the numbering is not intuitive.
    Thanks
    p.s.  We are using 11.5.3
    Edited by: Richard Keegan on Jun 13, 2008 5:18 PM

    Depending upon your query structure, you can force a zero based centerline by setting the Y-axis ranges dynamically.  I am not working in 11.5.3 currently, but ran into a problem with line charts in 12.0.2.  The zero centerline flag did not work, so I dynamically generated the ranges and linked them in.
    You can probably do the same with a little extra BLS coding.
    Mike

  • Stacked bar chart issue

    I have a stacked bar chart that works fine until one of the series involved returns no data - then it shows an empty chart with "no data found" on top. Anyone has any idea? Thanks

    Sorry for expressing my proposal in a wrong way. This is what I meant:
    http://htmldb.oracle.com/pls/otn/f?p=31517:46
    If you click on the dept 70 (which doesn't exist in my table) the chart will still show up. This workarround is good for the most of the cases where there is a requirement like yours. There , you will also find the chart query behind.
    The problem of no data found message was in my case present mostly there, where I needed to track a development of values grouped by time periods (months, quarters) and then query some portions of it.
    Denes Kubicek

  • Stacked Bar Chart - no data found

    I have a page with a report and a stacked bar chart. They are both based on the same query condition. When I call the page the report runs and shows the result but the chart shows "no data found" message. After pressing the submit button the chart finaly shows the result. Any clues what the problem could be? Can I create a process that would submit the page when I open it? Eventually only once per session?
    This is a funny behavior. It occurs only sometimes. I am not able to reproduce it by will.
    Denes Kubicek

    Hello Flavio,
    I know why this happened in my case - I added an additional condition using a page item as a bind variable to my ...WHERE... statement. This item had a default value.
    After that the chart showed no data found but everything else worked fine. As soon as I comment out that condition (I have plenty of similar conditions in that statement and they work), the chart would show as expected. It was like the chart select statement would see the item empty (NULL) but the report using the same conditions would find the default value in it.... after submitting the page, it worked fine for the rest of the session.
    Just now, I added a computation process for that page item, to set it on a static value (the same I had as the default value) - On Load Before Header. I also added a condition to it to fire only if the value of the item is NULL, to avoid unnecessary processing. After this my chart showed what was expected.....
    I am sure your problem is of a similar nature. You need to check your select statement I suppose.
    Denes Kubicek

  • Stacked Bar chart does not overlap series

    I have a stacked bar chart with to values "Invoiced" and "Budget" and 2 categories YEAR and MONTH - the problem is that the bar chart shows the values Invoiced and Budget in Top of each other and Not overlapping each other . ex:
    NOW:  Invoiced =  200   Budget = 300   - Bar chart shows a column of 500 for the month (NOT correct)
    What I want is to show 1 column for each month where up to 200 the colour is green and from 200 to 300 the colour is blue for example....
    How to achieve this ?

    Hi HCMJ,
    By default, the bar value will not overlapping each other in stacked bar chart, and we cannot increase or decrease the gap between the series in Reporting Services.
    Based on my research, I find a workaround can achieve your requirement, please refer to the steps below:
    Create a dataset with the query below (sample data):
    CREATE TABLE #temp(name nvarchar(50),time nvarchar(50),value int)
    INSERT INTO #temp VALUES     ('Invoiced','YEAR',100),('Invoiced','MONTH',200),('Budget','MONTH',300),('Budget','YEAR',600)
    SELECT * FROM  #temp
    Insert time field to Category Groups pane, and change the group name to “time”.
    Insert value field to Values pane, then change the value to like below:
    =min(Fields!value.Value,"time")
    Insert another field with the following expression to Values pane:
    =max(Fields!value.Value,"time")
    Change the type of chart from Stacked Bar Chart to Range Bar Chart.
    Right-click the Series field to change the Fill color to #9bff8c00 (DarkOrange with 155 Transparency) or any color with Transparency you like. Now we can get the following:
    Preview it and get the following result:
    If there are any other questions, please feel free to ask.
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • Stacked Bar Chart - Hiding legends with 0 values

    I'm using Crystal Reports 2008, building a report that will eventaully be called from an ASP.NET page.
    I've built a stacked bar chart that is displaying values per month of the number of various vehicle types.  The X values are the months, the Y values are the number of each vehicle type and the stacked series are each different vehicle type.  However, depending on the months that the user asks for, there may be some vehicle types that do not have any data, thus the number is 0.  Is there a way for the report to see that there is 0 data for this vehicle type and thus not include it in the legend of the various vehicle types?
    First time poster, so hopefully I explained everything well enough.  I searched the forums for anything matching Stacked Bar Chart and did not find anything.  I don't know how to find/query SAPNotes.
    Thanks.

    Thanks for the response, but I'm not familar with Alters?  Could you describe a bit more?  I didn't see anything in the documentation about it.

  • Question regarding 3-D stacked bar chart

    Hi All,
    I'm creating a report that has a view of a horizontal stacked bar chart. I was wondering if there's a way to portray that stacked bar chart as a 100% stacked bar chart like in ms excel?
    Thanks,
    Wayne

    Hi Wayne,
    I'm not sure if I understand your query correctly but I'll have a go at answering your question. I'm guessing that you have a horizontal bar chart that looks something like this, even after you've indicated that you want it to be a stacked chart -:
    |{color:#ff0000}@@@{color}
    |{color:#008000}#########{color}
    |{color:#ff00ff}++{color}
    |{color:#0000ff}===={color}
    However, you want it to look more like this -:
    |{color:#ff0000}@@@{color}{color:#008000}#########{color}{color:#ff00ff}++{color}{color:#0000ff}===={color}
    For the purposes of the example, let's assume you are using two fields for the bar chart - Account Type and *# of Accounts*. By default, your chart options would be set such that Account Type is the value used for the Y axis and *# of Accounts* is the value used for the X axis. Indicating that you want a stacked graph results in the first graph example I listed above. However, if you indicate that Account Type is the value to be used for the measure labels and that there is no value for the Y axis, then a stacked graph will look like the second graph example I listed.
    Hope this helps to answer your question.
    Regards,
    Cameron

  • BAM-Stacked bar chart

    hi,
    how to set Stacked bar chart horizontally instead of vertically(by default).

    Hi HCMJ,
    By default, the bar value will not overlapping each other in stacked bar chart, and we cannot increase or decrease the gap between the series in Reporting Services.
    Based on my research, I find a workaround can achieve your requirement, please refer to the steps below:
    Create a dataset with the query below (sample data):
    CREATE TABLE #temp(name nvarchar(50),time nvarchar(50),value int)
    INSERT INTO #temp VALUES     ('Invoiced','YEAR',100),('Invoiced','MONTH',200),('Budget','MONTH',300),('Budget','YEAR',600)
    SELECT * FROM  #temp
    Insert time field to Category Groups pane, and change the group name to “time”.
    Insert value field to Values pane, then change the value to like below:
    =min(Fields!value.Value,"time")
    Insert another field with the following expression to Values pane:
    =max(Fields!value.Value,"time")
    Change the type of chart from Stacked Bar Chart to Range Bar Chart.
    Right-click the Series field to change the Fill color to #9bff8c00 (DarkOrange with 155 Transparency) or any color with Transparency you like. Now we can get the following:
    Preview it and get the following result:
    If there are any other questions, please feel free to ask.
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • Workaround for NO DATA FOUND in stacked bar chart?

    Hello, Ive got a stacked bar chart in the making, when one of the series doesnt have data, the whole chart show the no data found message but not the other series that do have data. Is there a workaround for this? can I catch the exception in the Series Query? Or is there any other workaround someone has tried with success???
    thanks for any help or suggestion!!!

    Ok, figured out a workaround based on my rusted SQL memories (its probably not the most efficient way to go), made a view like this:
    CREATE OR REPLACE FORCE VIEW "VISTA1" ("NOMBRE", "TIPO_LOCAL", "TIPO", "FECHA", "OPCIONAL") AS
    select USUARIO.NOMBRE, USUARIO.TIPO TIPO_LOCAL, CONSUMO.TIPO, CONSUMO.FECHA, CONSUMO.OPCIONAL
    FROM USUARIO
    LEFT JOIN CONSUMO
    ON USUARIO.ID_USUARIO = CONSUMO.USUARIO_ID_USUARIO
    on this view, i made individual selects and UNIONed them for a comeplete table, with null values being zero, just what was needed:
    select null link,
    LOCAL,
    total "CANTIDAD"
    FROM
    select
    count(A.TIPO) TOTAL, 'SIGO SAMBIL' LOCAL
    FROM VISTA1 A
    where A.tipo='3 PACK' AND A.NOMBRE = 'SIGO SAMBIL'
    UNION
    select
    count(A.TIPO) TOTAL, 'A GRANEL' LOCAL
    FROM VISTA1 A
    where A.tipo='3 PACK' AND A.NOMBRE = 'A GRANEL'
    etc.....
    for each series, i then had to change the A.tipo value to whatever the new series should be.
    regards,
    Mariano.

  • How to create a stacked bar chart?

    How do you create a stacked bar chart in Visual Composer?
    I have a query with one keyfigure (amount) and drilldowns on Sales Org and Invoice Type. In my chart I want a bar for each Sales Org, and each bar should be divided in sections according to Invoice Type in one single stack. How can I create that?

    Hi
    Are you using BI query? If yes then follow the steps -
    1. Take Sales org in rows of BI query. & take invoice type & Key figure in Columns.
    2. In VC use this query & drag chart from the output of this query.
    3. Right click on chart & go to 'Configure Element'. There select Chart Type as 'Bar chart'
    4. Below that you will get default option as clustered, there you select 'Stacked'
    5. Create Data series as per your requirement.
    6. Arrange proper layout of the model & then deploy.
    You will get required output in stacked format.
    Regards
    Sandeep

Maybe you are looking for