我對cognos比較陌生,所以請記住這一點。cognos報告工作室多欄平均
我想創造在報告工作室的報告,其中i有3項措施(甲,乙,Ç)爲列和第三列計算作爲平均這些列。
但是,當使用平均函數時,我無法添加多個輸入。
我試圖算術替代(A + B + C)/ 3,因爲這將無法處理的情況下,當值均爲空
預先感謝您
我對cognos比較陌生,所以請記住這一點。cognos報告工作室多欄平均
我想創造在報告工作室的報告,其中i有3項措施(甲,乙,Ç)爲列和第三列計算作爲平均這些列。
但是,當使用平均函數時,我無法添加多個輸入。
我試圖算術替代(A + B + C)/ 3,因爲這將無法處理的情況下,當值均爲空
預先感謝您
如果空值不爲零的平均
case when
not (a is null and b is null and c is null)
then
(coalesce(a,0) + coalesce(b,0) + coalesce(c,0))/
(case when a is not null then 1 else 0 end +
case when b is not null then 1 else 0 end +
case when c is not null then 1 else 0 end)
end
感謝您的建議。然而,在這種情況下,平均值不會是(/ 3)它將需要在非空元素的數量上劃分 – CognosNewbie
我認爲這是解決問題的一種方法。我來到了一個類似的解決方案。如果這不是問題的答案,那麼需要對問題進行編輯以確保清晰。 – Johnsonium
我會創造一個價值數表達式計數非空列:
價值COUN牛逼
CASE WHEN [A] is not null THEN 1 ELSE 0
+
CASE WHEN [B] is not null THEN 1 ELSE 0
+
CASE WHEN [C] is not null THEN 1 ELSE 0
然後你就可以使用這個新的數據項作爲股息爲您平均值計算:
平均
(coalesce([A],0) + coalesce([B],0) + coalesce([C],0))/[Value Count]
如果除以0是一個問題,你可以用普通的表達在[Value Count]爲0時返回null的另一個CASE中:
CASE
WHEN [Value Count] > 0 THEN (coalesce([A],0) + coalesce([B],0) + coalesce([C],0))/[Value Count]
ELSE null
END
您可以計算abc並在nul然後0 – sagi