我正在尝试计算过滤日期列中MIN日期和最大日期之间的年数,然后将结果除以Y列X列的COUNT。
Spotfire文档说自定义表达式是操作过滤数据的关键,但我不确定如何将临时变量传递给SpotD函数,如DateDiff。
Example:
DateDiff(Min([Date]),Max([Date])) / [Column.Y] OVER [Column.X]
+------+----------+------------+
| Name | Date | Made Sale? |
+------+----------+------------+
| joe | 1/1/2010 | 10 |
| joe | 2/1/2011 | 11 |
| joe | 3/1/2012 | |
| joe | 4/1/2013 | 40 |
| joe | 5/1/2014 | |
| pam | 1/1/2010 | 100 |
| pam | 2/1/2011 | 19 |
| pam | 3/1/2012 | 23 |
| pam | 4/1/2013 | 30 |
| pam | 5/1/2014 | |
| mark | 1/1/2010 | |
| mark | 2/1/2011 | 1 |
| mark | 3/1/2012 | |
| mark | 4/1/2013 | |
| mark | 5/1/2014 | 49 |
+------+----------+------------+
EG. Filter from 2011-2014, what were Joe, Pam, and Mark's frequency of sales per year?
答案 0 :(得分:0)
您需要将其包装在IF()或CASE等逻辑语句中。
If(DatePart('year',[Date]) >= Year('2011') and DatePart('year',[Date]) <= Year('2014'),DateDiff(Min([Date]),Max([Date])) / [Column.Y] OVER [Column.X])
您可以使用财产控制并传入任何输入或计算的年份来代替'2011'和'2014'。它看起来像
Year('${yourPropertyControlName}')