[英]Ranking in Tableau Based on another Field
How to rank based on a field where the value is the same.如何根据值相同的字段进行排名。 There is some more ranking applied here and this scenario need to be addressed as well as I can not rank again by Sales field .这里应用了更多排名,需要解决这种情况,因为我无法通过 Sales 字段再次排名。 Instead, I need to say:相反,我需要说:
If Unit is the same on the list of territories, rank based on Sales.如果地区列表中的单位相同,则根据销售额排名。
Example:例子:
Terr Sales Unit Should look like : Terr Sales Unit
---- ------ ----- -----------------------
Boston 1 5 Maine 10 5
Maine 10 5 Boston 1 5
Often a mathematical approach works well for this.通常,数学方法对此很有效。 First, without wanting to patronise, it's possible to use a discrete (blue) measure to sort data.首先,不想光顾,可以使用离散(蓝色)度量对数据进行排序。 Place the sorting pill to the far left on the Rows and the table will sort according to this pill.将排序药丸放在 Rows 的最左侧,表格将根据该药丸进行排序。
Ok, so the formula.好了,公式就出来了。 Without knowing how large the Sales figure can go, you want to create a calculation that would give the highest value to that you want to appear top.在不知道 Sales 数字可以达到多大的情况下,您想要创建一个计算,该计算将为您希望出现在顶部的那个提供最高值。
For example perhaps multiple Unit by 1,000,000 and add Sales.例如,可能将单位乘以 1,000,000 并添加销售额。 Just make sure the Units are multiplied by a number large enough to make Sales inconsequential.只需确保单位乘以一个足够大的数字,以使销售额无关紧要。
This field may work, depending how large the Sales figure can go:此字段可能有效,具体取决于销售额数字的大小:
[SortField] = (SUM([Unit])*1000000 + SUM([Sales])) * -1 [SortField] = (SUM([Unit])*1000000 + SUM([Sales])) * -1
Put the field to Rows, convert to Discrete, then place to the far left.将字段置于 Rows,转换为 Discrete,然后置于最左侧。 If the sorting is correct hide the field header.如果排序正确隐藏字段标题。
It multiplies by -1 to sort descending.它乘以 -1 以进行降序排序。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.