简体   繁体   English

在 PowerBI 中使用不同的列制作堆叠条

[英]Making a stacked bar using different columns in PowerBI

Hi I'm Trying to take data in PowerBI that looks like this嗨,我正在尝试在 PowerBI 中获取如下所示的数据

数据表

It basically has several columns with reason for call and the length of time in each one - the time varies它基本上有几列,其中包含呼叫原因和每一列的时间长度 - 时间各不相同

Reason1 Reason2 Reason3
--       30 secs   30 secs
60 secs   1 min    ----
---       2 min    ----

I need a graph that shows each of these reason split by the length of calls我需要一个图表,显示按调用长度划分的每个原因

首选视觉

thank you (I am also an amateur at PBI so be gentle)谢谢(我也是 PBI 的业余爱好者,所以要温柔)

You need to flatten your table into a two column layout.您需要将表格展平为两列布局。 Edit the data source in the Query editor.在查询编辑器中编辑数据源。 Starting out, it may look like this:开始时,它可能如下所示: 在此处输入图片说明

Select all columns and click the Unpivot Columns command in the Transform ribbon.选择所有列,然后单击“变换”功能区中的逆透视列”命令。 Now your data looks like this:现在您的数据如下所示:

在此处输入图片说明

Rename "Attribute" to "Category" and rename "Value" to "Time Frame".将“属性”重命名为“类别”,将“值”重命名为“时间框架”。 Filter the Time Frame column and untick Blanks.过滤 Time Frame 列并取消勾选空白。

在此处输入图片说明

Close and apply the query.关闭并应用查询。

Now you can build a stacked horizontal bar chart.现在您可以构建堆叠的水平条形图。 Put "Category" on the Axis and drag "Time Frame" into the values.将“类别”放在轴上并将“时间框架”拖到值中。 Since it is text, it will be aggregated with a Count.既然是文本,就会用一个Count来聚合。 Drag "Time Frame" into the legend to give each time frame its own colour.将“时间框架”拖到图例中,为每个时间框架赋予自己的颜色。 Viola!中提琴!

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM