[英]TiBCO Spotfire - How to Calculate only the last 3 columns in a Data - see descr
Week Sales
1 100
2 250
3 350
4 145
5 987
6 26
7 32
8 156
I wanted to calculate the sales only for the last 3 weeks so the total will be 156+32+26. 我只想计算最近3周的销售额,所以总数将为156 + 32 + 26。
If new weeks are added it should automatically calculate only the data from the last 3 rows. 如果添加了新的星期,则应该仅自动计算最近3行中的数据。
Tried this formula but it is returning an incorrect sum 尝试过此公式,但返回不正确的总和
sum(sales) over (lastperiod(3(week))
https://i.stack.imgur.com/6Y7h7.jpg https://i.stack.imgur.com/6Y7h7.jpg
If you want only the last 3 weeks sum in calculated column you can use a simple if calculation. 如果只想在计算列中提供最近3周的总和,则可以使用简单的if计算。
If([week]>(Max([week]) - 3),Sum([sales]),0)
If you need 3 weeks calculation throughout table use below one. 如果您需要在整个表格中进行3周的计算,请使用以下一项。
sum([sales]) OVER (LastPeriods(3,[week]))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.