Power BI中的排序堆栈条形图 [英] sorting stack bar chart in power BI
问题描述
我正在使用堆积的条形图来表示各个地区的性别比例。
图例是性别,轴是地区,价值是员工人数。
当我想根据女性性别值对图表进行排序时。排序仅根据人数值进行。如何将其排序为百分比值。请帮助我。
I am using a stacked bar chart for presenting the gender ratio in various region. here the legend is gender and Axis is region and value is headcount. when i want to sort the chart according to female gender value . the sorting is only done by the headcount value. how can i sort it for the percentage value. please help me.
推荐答案
编辑:我的第一个答案仅关注计数,现在我考虑到了OP希望按女性价值百分比进行排序
您可以直接在堆叠的柱形图
可视化,在旋转数据
并添加列
之后显示使用 Power Query Editor
的女性百分比值。如果将女性比率作为 Tooltip
插入,则即使图表中未显示该比率,也可以将其作为该值进行排序。
You can sort your data directly in your Stacked column chart
visualization, after pivoting the data
and adding a column
showing the female percentage value using the Power Query Editor
. If you insert the female ratio as a Tooltip
, your chart can be sorted as that value even though it is not displayed in your chart.
以下是详细信息:
此数据示例应符合您的描述:
This data sample should fit your description:
Region,Gender,Count
USA,M,9000
USA,F,7000
EU,M,5000
EU,F,5000
UK,M,2000
UK,F,4000
CAN,M,100
CAN,F,900
如果您使用Edit Queries / Power Query Editor输入该数据,则可以这样设置:
If you enter that data using Edit Queries / the Power Query Editor, you can set it up like this:
现在突出显示性别列,然后选择变换>枢轴要获取此信息的列:
Now highlight the Gender column, and select Transform > Pivot Column to get this:
在值列
下,选择计数
,然后单击确定
来获取此信息:
Under Values Column
, select Count
and click OK
to get this:
现在simpy添加一个自定义列来计算女性比例,如下所示:
Now simpy add a custom column to calgulate the female ratio like so:
现在您的表格应如下所示:
Now your table should look like this:
在桌面上,插入一个堆积的柱形图,然后进行如下设置。请注意,您需要在工具提示
下插入 F比率
:
In the desktop, insert a stacked column chart and set it up like below. Notice that you'll need to insert F ratio
under Tooltips
:
现在,您可以按升序$ c $对图表进行排序c>或
降F比率
这篇关于Power BI中的排序堆栈条形图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!