我正在寻找有关创建度量的帮助,该度量是其自身的百分比或列总数的百分比。目前我必须创建聚合(客户)的副本,然后创建格式值 - >显示为总列数的百分比。我想明确表示%。
示例:
State | Customers | New Measure
GA | 500 | 50%
SC | 250 | 25%
NY | 250 | 25%
我希望根据我在PowerPivot表中使用的任何过滤器或行列来更新此度量。
答案 0 :(得分:1)
使用此表达式:
string[] lines = File.ReadAllLines(path);
List<Bus> results = new List<Bus>();
//Bus = class with all the vars in it
//such as Bus.ID, Bus.COLD, Bus.YYYYMMDD
foreach (line in lines) {
var val = line.Split("\\s+");
//not sure where to go from here
}
它将创建一个名为%cust = FORMAT((Sum(Tabla[Customers])/1000),"0%")
的度量,格式为百分比,不带小数。如果您想获取小数,只需将%cust
替换为"0%"
。
如果有帮助,请告诉我。
答案 1 :(得分:0)
这个公式适合我。
{{1}}
哦,我将度量格式化为%,因为值为1
答案 2 :(得分:0)
定义总和度量 -
[cust_msr]:
=sum(table[cust])
定义%度量:
[Cust%:]=
divide(
[cust_msr]
,CALCULATE([cust_msr],ALL(table))
,blank())
使用除法是最佳做法,因为它意味着将任何错误值设置为空值。当然,如果您愿意,可以将它们设置为0或-1等。
此外,在powerpivot窗口中设置度量数据类型,您不需要格式化()