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

  • SEARCH
  • Home
  • 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 456k
  • Answers 456k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

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

    • 7 Answers
  • Editorial Team

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

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer It means that it matches without consuming any characters. It… May 15, 2026 at 10:37 pm
  • Editorial Team
    Editorial Team added an answer It turns out that most browsers support Ajax, so I'm… May 15, 2026 at 10:37 pm
  • Editorial Team
    Editorial Team added an answer No, .NET (as well as any native program) will not… May 15, 2026 at 10:36 pm

Trending Tags

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

Top Members

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.