2017-08-15 174 views
0

我試圖計算基於下表上的流失率: 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 任何想法如何使它工作嗎?

回答

1

解決它自己

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