问题描述
假设我正在为名为Air Holland"的客户创建饼图,对于该客户,我想在饼图中显示与其他客户的重叠,包括名为Air England"、Air Ireland"和冰岛航空".由于我的客户的隐私规定,我只能显示部分名称,例如他们名字的前三个或四个字母.'Air Holland' 因此更改为 'Air xxxxxxx'
Say I am creating a pie chart for customer called 'Air Holland', for this customer I would like to show the overlap with other customers in a pie chart, including customers called 'Air Hungary', 'Air Ireland' and 'Air Iceland'. Due to privacy regulations of my customers I can only show partial names, e.g. the first three or four letters of their name. 'Air Holland' thus changes to 'Air xxxxxxx'
现在为了在我的饼图中实现这一点,我创建了一个新的 CustomerNameMasked 列,它采用客户名称,并将除前四个字符之外的所有字符替换为x".理想情况下,我想在饼图中使用 CustomerName 作为图例,然后使用 CustomerNameMasked 作为标签,这样饼图是使用 CustomerName 创建的,但会显示被屏蔽的名称.
To implement this now in my pie chart, I have created a new Column CustomerNameMasked that takes the customer name, and replaces all characters but the first four with an 'x'. Ideally I would like to use CustomerName as the Legend in my pie chart, and then the CustomerNameMasked as the label, such that the pie chart is created using CustomerName, but will show the masked names.
但是,据我所知,这样的标签是不可能的,所以现在我使用 CustomerNameMasked 作为我的图例列.但由于这些名称不是唯一的(例如,匈牙利航空公司"和荷兰航空公司"在 CustomerNameMasked 列中都是航空公司 xxxxxxx"),因此会将不同的客户放在一起.
However, as far as I know such a label is not possible, so now I have used CustomerNameMasked as my Legend column. But since these name are not unique (e.g. 'Air Hungary' and 'Air Holland' are both 'Air xxxxxxx' in the CustomerNameMasked column), different customers are taken together.
任何想法如何创建独特的蒙面客户名称?或者另一种解决方法,以确保我的饼图正确显示每个客户的数据,但图例显示被屏蔽的名称?
Any ideas how to create unique masked customer names? Or another work-around to ensure that my pie chart correctly shows the data per customer, but the legend shows masked names?
推荐答案
防止匿名名称在可视化中合并的一种方法是确保它们不相同.
One way of preventing anonymised names from being merged in visualisations is to make sure they are not the same.
添加计算列:
Anonymised = "Airline " & RANKX('MyTable','MyTable'[CustomerName],,ASC,Dense)
结果:
Airline 1
Airline 2
Airline 3
...
如果你更喜欢 x
的:
添加一个Anonymised_Name
表,
Name Anonymised Name
"Air Holland" "Air xxxxxxx"
"Air Hungary" "Air xxxxxxx "
"Air Iceland" "Air xxxxxxx "
使用假空间"(小键盘上的 alt+0160)来防止 PowerBI 将其吞噬.添加关系并在可视化中使用此列.
Use "fake space" (alt+0160 on the numpad) to prevent PowerBI from swallowing it up. Add a relationship and use this column in visualisations.
我更喜欢以前的选项,因为它更容易区分和跟踪单个客户.
I prefer previous option as it makes it easier to distinguish and keep track of individual customers.
如果你不在乎x"的数量是否与真实姓名匹配:
If you don't care whether number of "x"s matches real name:
Anonymised_Name_2 = "Air XXXXXXX" & REPT(" ",
RANKX('MyTable','MyTable'[CustomerName],,ASC,Dense))
(又是假空格 alt+0160)
(again fake space alt+0160)
根据您对报告的处理方式,真实客户姓名泄露"的风险很大,因此理想情况下,您希望在导入数据之前对其进行匿名化处理.
Depending on what you do with your report, there is a significant risk of real customer names "leaking", so ideally you would want to anonymize your data before importing it.
这篇关于如何在 PowerBI 中匿名/屏蔽部分字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!