Excel 图表 - 类别和子类别分组

发布于 2024-12-08 12:11:59 字数 985 浏览 0 评论 0原文

我很少使用Excel,对图表和绘图相关函数没有深入的了解。话虽如此...

我有几十行数据,由 4 列组成,

  • 第 1 列 = 金额/价格(以数字表示)
  • 第 2 列 = 描述(什么 在文本中)
  • 第 3 列 = 类别(在文本中)
  • 第 4 列 = 子类别(在 文本)

我想制作数据行的条形图,以便最终结果如下所示:

X 轴 - 类别 Y 轴 - 数量/价格

这里的技巧是类别不要重复。例如,如果我们的数据类似于...

  • 100 |船购买|船 | 3 引擎船
  • 200 |船购买| 船 | 2 引擎船
  • 500 |飞机购买 |飞机 | 4 引擎飞机
  • 900 |购车 |汽车 | 1 引擎汽车

那么我的图表中应该只有一个船、飞机和汽车的实例,所有相关数据将汇总在该实例下。

最后但并非最不重要的一点是,我看到过一些图表,其中这些独特的不重复的类别不仅仅是一个“条形”,可以说是由较小的条形组成的。在这种情况下,我希望这些较小的条形图成为子类别,以便最终结果如下所示:

basic and complex图表示例

在该示例图像中,我首先呈现一个“基本、经典”图表,其中蓝色、黄色和红色分别代表一个独特的不同类别。正下方是我想要的,按子类别对每个类别进行“细分”,其中蓝色/黄色/红色分别代表每个类别的虚构 3 个不同子类别。

这意味着每个类别的子类别都会重复,但类别本身不会重复。

需要澄清的是,我目前只有 3 个主要类别和 6 个左右的子类别,但这在未来可能会改变,因此希望以自动/动态的方式实现这一点

。 G.Campos

编辑:新图像:

更好地解释所需的图形结果

I seldom if ever use excel and have no deep understanding of graphs and graphing-related functions. Having said that...

I have dozens of rows of data, composed by 4 columns

  • column 1 = amount/price (in numbers)
  • column 2 = description (the what
    in text)
  • column 3 = category (in text)
  • column 4 = subcategory (in
    text)

I want to make a bar graph of my rows of data so that, the end result looks like this:

X axis - categories
Y axis - amount/price

The trick here is for categories NOT to repeat themselves. For example, if our data is something like...

  • 100 | boat purchase | boats | 3 engine boat
  • 200 | boat purchase |
    boats | 2 engine boat
  • 500 | plane purchase | planes | 4 engine plane
  • 900 | car purchase | cars | 1 engine car

Then there should only be ONE instance of boats, planes and cars in my graph, under which all associated data would be summed up.

Last but not least, I have seen graphs where, these unique-not-repeated categories, instead of just being one single 'bar' so to speak, are composed of smaller bars. In this case, I want these smaller bars to be the sub categories, so that the end result would look like this:

basic and complex graph samples

In that sample image, I first present a 'basic, classic' graph where blue, yellow and red each represent a unique, different category. Right below it is what I want, a 'breakdown' of each category by subcategory where blue/yellow/red each represent an imaginary 3 different subcategories per category.

This means subcategories will repeat themselves for each category, but categories themselves will not.

For clarification, I currently only have 3 main categories and 6 or so sub-categories, but this could change in the future, hence the desire to have this in an automatic/dynamic fashion

Kind regards
G.Campos

EDIT: new image:

better explanation of desired graph result

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

扬花落满肩 2024-12-15 12:11:59

这是我的看法。不幸的是,我无法发布屏幕截图,因为我没有足够的帖子。

一种解决方案是使用数据透视图,将金额放在“值”中,将类别放在“行标签”中,将子类别放在“列标签”中。

我在免费图像上传服务上上传了相关图像。

这是我们的源数据:

Amount  Decription  Category    SubCategory
100     boat purchase   boats   3 engine boat
200     boat purchase   boats   2 engine boat
500     plane purchase  planes  4 engine plane
900     car purchase    cars    1 engine car
450     boat purchase   boats   2 engine boat
110     plane purchase  planes  4 engine plane
550     car purchase    cars    1 engine car
230     car purchase    cars    2 engine car
450     car purchase    cars    5 engine car

这是所需的图表(编辑:这有幽灵条):

http://imageshack.us/photo/my-images/849/pivot.gif/

我刚刚读了关于没有鬼图的评论。这可能就是您正在寻找的内容:

http://imageshack.us/photo /my-images/266/pivotnoghost.gif/

刚刚用谷歌搜索,发现了一些非常相似的东西:

peltiertech.com/WordPress/using-pivot-table-data-for-a-chart-with-a-dual-category-axis/

您需要添加 http:// (由于我不能有两个以上的超链接帖子数量少)

Here i my take on it. Unfortunately I can't post the screenshots as I don't have enough posts.

One solution is to use pivot charts put Amount in "Values", Category in "Row Lables", and SubCategory in "Column Labels".

I uploaded relevant images on a free image upload service.

This is our source data:

Amount  Decription  Category    SubCategory
100     boat purchase   boats   3 engine boat
200     boat purchase   boats   2 engine boat
500     plane purchase  planes  4 engine plane
900     car purchase    cars    1 engine car
450     boat purchase   boats   2 engine boat
110     plane purchase  planes  4 engine plane
550     car purchase    cars    1 engine car
230     car purchase    cars    2 engine car
450     car purchase    cars    5 engine car

This is the desired graph (Edit: This has ghost bars):

http://imageshack.us/photo/my-images/849/pivot.gif/

I just read the comment about no ghost graphs. This might be what you are looking for:

http://imageshack.us/photo/my-images/266/pivotnoghost.gif/

Just googled and found something very similar here:

peltiertech.com/WordPress/using-pivot-table-data-for-a-chart-with-a-dual-category-axis/

You need to add http:// ( I can't have more than two hyperlinks due to low number of posts)

亚希 2024-12-15 12:11:59

我不确定这是否能让您准确地到达您想要的位置,但我发现一般来说,在 Excel 中,在单独的选项卡上汇总图形数据是最简单的。

对于这样的示例数据

dataset

您将在工作表中创建第二个选项卡,其显示类似于

summary data

使用 sumif 公式计算类别

=SUMIF(Data!C:C,Summary!A2,Data!A:A)

总计

=SUMIF(Data!D:D,Summary!E2,Data!A:A)

子类别总计(假设子类别相互) 独家的)。现在已汇总数据,突出显示单元格并为以下图表插入柱形图。

pretty Charts

添加新类别和/或子类别将要求您向摘要数据添加行,然后将系列添加到图表。您可以使用 vba 宏来自动执行该任务,但我怀疑这太过分了,因为您的数据集是“数十个”而不是“数千个”

I am not sure this will get you exactly where you want but I find in general in excel it is easiest to summarize your graph data on a separate tab.

For sample data like this

dataset

you would create a 2nd tab in the sheet that appears something like

summary data

the totals are calculated by using the sumif formula

=SUMIF(Data!C:C,Summary!A2,Data!A:A)

For the Category totals

and

=SUMIF(Data!D:D,Summary!E2,Data!A:A)

For the sub category totals (Assuming sub-categories are mutally exclusive). Now that that data is summarized, highlight the cells and insert a column chart for the following charts.

pretty charts

Adding new categories and/or sub categories will require you to add lines to the summary data, and then add series to the charts. You could use a vba macro to automate that task but I suspect that is overkill since your dataset is "dozens" rather than "thousands"

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文