百分比表计算

问题描述:

我试图计算基于下表上的流失率: enter image description here百分比表计算

例如,有在1月22日的条目,4留在第一个月。我想有百分比以下逻辑:

  1. 1 - 4/22 = 0,81
  2. 1-4/22 - 1/22 = 0,77

在的Tableau创建计算字段:

1 - 

SUM([Number of Records])/TOTAL(SUM([Number of Records])) 

- ZN(LOOKUP(SUM([Number of Records])/TOTAL(SUM([Number of Records])), -1)) 

但它仅适用于第2个月: enter image description here 任何想法如何使它工作吗?

解决它自己

IF NOT ISNULL(SUM([Number of Records])) THEN 
(TOTAL(SUM([Number of Records])) 
- RUNNING_SUM(SUM([Number of Records])) 
+ ZN(SUM([Number of Records])) - SUM([Number of Records]))/TOTAL(SUM([Number of Records])) 
END