Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.charting
Paddy
 
Posts: n/a
Default How to chart a single column of values similar to a GROUP BY

Hi

I would like to create a chart of a column of non numeric values where the
column label would be the value and the chart would reflect the number of
occurences of the value in the column eg.

brown
blue
blue
brown
brown

this would produce two bars on the chart labled brown and blue with values
of 3 and 2 respectively.

It is the same as a GROUP BY function in SQL

Any help is really appreciated.

Thanks

Paddy
  #2   Report Post  
Posted to microsoft.public.excel.charting
Greg Wilson
 
Posts: n/a
Default How to chart a single column of values similar to a GROUP BY

Assuming the list of colours are already entered in Range("A1:A100") then:
1. In cell B1 enter Blue
2. In cell B2 enter Brown
3. If there are more colours then continue entering (B3, B4... etc)
4. In cell C1 enter: "=CountIf($A$1:$A$100, B1)"
5. Drag the formula down to the end of the list in column B (C2 if only two
colours)
6. Select the cells containing the colour list and formulas (cols B and C)
and plot them as a Column chart

If the colour list in column A is variable in length then I think I would go
with a Dynamic Named Range in place of "A1:A100". If not familiar I can
describe.

Regards,
Greg





"Paddy" wrote:

Hi

I would like to create a chart of a column of non numeric values where the
column label would be the value and the chart would reflect the number of
occurences of the value in the column eg.

brown
blue
blue
brown
brown

this would produce two bars on the chart labled brown and blue with values
of 3 and 2 respectively.

It is the same as a GROUP BY function in SQL

Any help is really appreciated.

Thanks

Paddy

  #3   Report Post  
Posted to microsoft.public.excel.charting
Paddy
 
Posts: n/a
Default How to chart a single column of values similar to a GROUP BY

Hi Greg

Thanks, worked great.

One further question on this. Col A will have any number of entries. Is
there a way for me to get a "distinct" list of the values contained in it for
use in Col B

Thanks

Paddy

"Greg Wilson" wrote:

Assuming the list of colours are already entered in Range("A1:A100") then:
1. In cell B1 enter Blue
2. In cell B2 enter Brown
3. If there are more colours then continue entering (B3, B4... etc)
4. In cell C1 enter: "=CountIf($A$1:$A$100, B1)"
5. Drag the formula down to the end of the list in column B (C2 if only two
colours)
6. Select the cells containing the colour list and formulas (cols B and C)
and plot them as a Column chart

If the colour list in column A is variable in length then I think I would go
with a Dynamic Named Range in place of "A1:A100". If not familiar I can
describe.

Regards,
Greg





"Paddy" wrote:

Hi

I would like to create a chart of a column of non numeric values where the
column label would be the value and the chart would reflect the number of
occurences of the value in the column eg.

brown
blue
blue
brown
brown

this would produce two bars on the chart labled brown and blue with values
of 3 and 2 respectively.

It is the same as a GROUP BY function in SQL

Any help is really appreciated.

Thanks

Paddy

  #4   Report Post  
Posted to microsoft.public.excel.charting
Greg Wilson
 
Posts: n/a
Default How to chart a single column of values similar to a GROUP BY

By "distinct list" I am assuming you meant a list of UNIQUE values contained
in column A - i.e. I am assuming there are more colours than just blue and
brown and you want to obtain a list of only unique colours.

I suggest using a Dynamic Named Range for the entries in column A. If you
are not familiar, the definition of this named range automatically adusts to
the number of entries. These are particularly usefull for charting.

***********************************
To create the Dynamic Named Range:

1. Open the Define Name dialog: Insert Name Define
2. In the "Names in workbook:" window enter: ColourListRng
3. In the "Refers to:" window enter:
=OFFSET(Sheet1!$A$1, 0, 0, COUNTA(Sheet1!$A:$A), 1)
The above formula assumes that the name of the worksheet is "Sheet1" and the
colour list starts at cell A1. Change to suit. The formula will require
adjustment if there are more data in column A below the colour list.
4. Click the Add button.
5. Close the dialog.

******************************
Macro to extract unique values from the colour list in column A
(ColourListRng). These extracted values will be copied to column B:

Sub GetUniques()
Dim r As Range, r2 As Range
Dim c As Range, cc As Range
Dim ws As Worksheet

Set r = Range("ColourListRng")
Set ws = r.Parent
Set c = r(1)
Set cc = r(1, 2)
For Each c In r
Set r2 = ws.Range(r(1), c)
If Application.CountIf(r2, c) = 1 Then
cc = c
Set cc = cc(2)
End If
Next
End Sub

********************************
Required change to formula that counts instances of each colour:
In place of the formula I gave you earlier:
=CountIf($A$1:$A$100, B1)
Substitute:
=CountIf(ColourListRng, B1)

Drag this formula down as instructed earlier.

********************************
How to test accuracy of ColourListRng:
1. Open the Define Names dialog again and click inside the "Refers to:"
window. The entries in the list and only these cells should be highlighted
with dashed lines.
2. Change the number of entries in the list and retest to ensure it adjusts
correctly. Post if it does not.


Regards,
Greg
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Column Chart with 2 values in each column Alec Green Charts and Charting in Excel 2 February 25th 05 06:12 AM
To create a stacked column chart and group the stacked bars togeth Jacqueline Charts and Charting in Excel 1 February 17th 05 11:05 PM
How do i group together different charts into a single chart in e. Mukund Charts and Charting in Excel 2 February 14th 05 02:46 PM
hide column but show chart Svetlana Charts and Charting in Excel 1 January 14th 05 09:49 AM
Subtotal of Subtotal displays Grand Total in wrong row Thomas Born Excel Worksheet Functions 5 January 6th 05 01:46 PM


All times are GMT +1. The time now is 11:14 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"