如何在 Power BI 的矩阵中按列排序.
How can I sort by columns in Matrix in Power BI.
让我解释一下.我有这张表(示例).
Let me explain a bit. I have this table (sample).
有单位和评级(总是会经常添加新单位).
There is Unit and Rating (New Units will be always added often).
我尝试在 Power BI 的 Matrix 中显示数据,我得到了这个,但我根本无法按高、中或低排序.
I try to show the data in Matrix in Power BI and I got this but I can't sort by High, Medium or Low at all.
我想按这个顺序(High Desc、Medium Desc 和 Low Dec)排序.
I want to sort in this order (High Desc, Medium Desc and Low Dec) order.
我怎样才能实现它?我是 Power BI 的新手.
How can I achieve it? I am quite new to Power BI.
推荐答案诀窍是创建一个订单列并将该排序与 按列排序功能.
The trick is to create an order column and use that sort on with the Sort by Column feature.
但问题是,如果您编写这样的计算列:
The problem though is if you write a calculated column like this:
Order = SWITCH(Table1[Rate], "High", 1, "Medium", 2, "Low", 3)然后尝试对其进行排序,然后您会收到一个循环依赖错误,基本上是说您无法按依赖于您尝试排序的列的列进行排序.
and then try to sort on that, then you'll get a circular dependency error basically saying you can't sort by a column that is dependent on the column you are trying to sort.
有几种解决方法.
一种可能性是在查询编辑器中创建您的订单列,它应该是一个简单的自定义列:
One possibility is to create your order column in the query editor, which should be a simple custom column:
if [Rate] = "High" then 1 else if [Rate] = "Medium" then 2 else if [Rate] = "Low" then 3 else 0使用此列进行排序.
另一种可能性是根据您的订购偏好定义一个新表.
Another possibility is to define a new table that with your ordering preference.
输入数据:
Rate Order ------------- High 1 Low 3 Medium 2调用此表Sort并在Rate列上创建与原始表的关系.
Call this table Sort and create a relationship with the original table on the Rate column.
现在在原始表上创建一个计算列,用于提取 Order 值.
Now create a calculated column on the original table that pulls over the Order value.
Order = RELATED(Sort[Order])使用此列进行排序.
更多推荐
如何在不使用度量的情况下在 Power BI 中按矩阵中的列排序
发布评论