Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 894205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T14:20:45+00:00 2026-05-15T14:20:45+00:00

I’m using Microsoft Chart extensions that ship with VS 2010. This suits my needs

  • 0

I’m using Microsoft Chart extensions that ship with VS 2010. This suits my needs well, but I’ve run into an annoyance and am looking for a more elegant solution.

When charting a line graph, to achieve a continuous line, I require data for all X coordinates. My dataset is for number of sales by employee by month, where sales count is on the Y and month is on the X. The problem arises where no data is returned for an X value (ie. An employee took a month off)…so the line is not continuous.

I’m not sure if there is a setting I’ve overlooked in the Chart control, but my inelegant solution is to create ‘fake’ zero sales data for the months the employee posted no sales.

I’m using a stored procedure in MS SQL to create my dataset, where each column is a month and each row is for an employee. I create a new series in the Chart control for each employee then.

In order to capture my zero sales months, I have created a temp table in SQL.

CREATE TABLE @tblMonth (myMonth nvarchar(10), defaultCount int)
INSERT INTO @tblMonth VALUES (‘January’, 0)
…
INSERT INTO @tblMonth VALUES (‘December’, 0)

I then perform a join of my temp table on my actual data record and use

ISNULL (realData.Count, tblMonth.defaultCount) 

To get my ‘fake’ zero sales data.

This works…but FEELS really kludgy to me…I can’t help but feel I’ve overlooked something simple that would better suit my purposes. Again, I’ve got this working…but always looking for better ways of doing things and expand my knowledge base….so if anyone has suggestions of how better to accomplish the above, I’d love some suggestions or feedback.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T14:20:46+00:00Added an answer on May 15, 2026 at 2:20 pm

    If tblMonth.DefaultCount will always be zero, then why not:

    ISNULL (realData.Count, 0)
    

    Here’s what I am guessing your query looks like:

    SELECT
      sales_month = DATENAME ( month, s.sale_date )
      , sales_month_n = DATEPART( month, s.sale_date)
      , salesperson = e.employee_name
      , numb_of_sales = COUNT ( 1 )
    
    FROM
     sales s
     JOIN employee e
       ON s.employee_id_salesperson = e.employee_id
    WHERE s.sale_date >= '1/1/2010' and s.sale_date < '1/1/2011'
    GROUP BY 
      DATENAME ( month, s.sale_date ), e.employee_name, DATEPART( month, s.sale_date)
    

    –which works fine, until you have an employee take off in June, July and August. You still want them to show up in the resultset, but with zero sales

    CREATE TABLE @tblMonth (myMonth nvarchar(10), n tinyint) 
        INSERT INTO @tblMonth VALUES ('January', 1) 
        ... 
        INSERT INTO @tblMonth VALUES ('December', 12)
    
    
    SELECT
        all_possibles.sales_month
        , all_possibles.salesperson
        , ISNULL ( actual.numb_of_sales, 0 )
    FROM 
        (
            SELECT
              sales_month = myMonth
              , sales_month_n = n
              , salesperson = e.employee_name
            FROM
                employee e
                ,@tblMonth M
        )all_possibles
        LEFT JOIN 
        (
            SELECT
              sales_month_n = DATEPART( month, s.sale_date)
              , salesperson = e.employee_name
              , numb_of_sales = COUNT ( 1 )
            FROM
             sales s
             JOIN employee e
               ON s.employee_id_salesperson = e.employee_id
            WHERE s.sale_date >= '1/1/2010' and s.sale_date < '1/1/2011'
            GROUP BY 
               e.employee_name, DATEPART( month, s.sale_date)
        )actuals
            ON 
            (
                all_possibles.salesperson = actuals.salesperson
                AND all_possibles.sales_month_n = actuals.sales_month_n
            )
    

    Sorry for the long winded answer. Hope you feel reassured that you are on the right track. Good luck!

    As to kludgy – instead of @tblMonth, I use permanent tables in a utility / resource database. it is already populated with things like a record for every minute in the day, or in this case, a record for every month in a year. These types of tables, forget what they are called – maybe a form of fact table? are VERY useful when looking for or filling in gaps in data.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 539k
  • Answers 539k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer As far as I know only the log4j.properties of the… May 17, 2026 at 2:23 am
  • Editorial Team
    Editorial Team added an answer Use autocomplete="off" as in Google homepage May 17, 2026 at 2:23 am
  • Editorial Team
    Editorial Team added an answer doo will not work as it is. It would need… May 17, 2026 at 2:23 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I am using Microsoft Visual C++ 2010. If I have a function like this:
I'm using the Microsoft Chart Controls, and displays data with dates along the X
I'm using the Microsoft Chart Controls for Microsoft .NET Framework 3.5 and am having
I am using a Microsoft Chart control (system.windows.forms.datavisualization.charting.chart) in a Windows forms application, vb.net
I'm using the Microsoft Chart Controls for .NET 3.5 and am struggling with getting
I am using Microsoft's CDO (Collaboration Data Objects) to programmatically read mail from an
I am using the ilovesharepoint Lookup Field with Picker that is on codeplex on
I have a bar chart with horizontal bars. I used this article to setup
I'm a beginner starting to use Microsoft Visual C++ Express 2010 for Windows Programming.
I am writing a library that I would like to be portable. Thus, it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.