我需要创建一个报告,对于每个列,将有一个前一列,它将从作为输入的日期开始的18个月后的日期给出值。基本上我在特定日期从几列到Spotfire
获取数据,并希望很少的列显示18个月前的输出。
代码摘要 -
这是我必须在Spotfire
中实现的代码。此报告记录特定单日的日期输入并获取其列值。子查询获取少量值,并将它们发送到主查询。通常这个报告有
几个常见列和少数其他列具有相同列的当前日期和先前日期的值。我可以实现主查询中的所有列,但是需要建议来获取在Spotfire
中计算的先前列的值,或者无论如何都要实现为Oracle view
,因为我们将只获得一个主要输入查询和子查询将扣除静态日期/月份[在这种情况下为18个月]
代码示例: -
select st.x1,
cs.x2 ,
sp.x3, sp.x4,
el.x5 current_zxc, --New data 2
el.xxxx current_zvvxx, --New data 3
por.x6 current_zczxc, --New data 4
el.x7 current_sdcvzv, --New data 5
prev_yr_data.prev_1 previous_czzxczxc,
prev_yr_data.prev_2 previous_xcvv,
prev_yr_data.prev_3 previous_zcvzxz,
prev_yr_data.prev_4 PREVIOUS_czxcvzxv,
prev_yr_data.prev_5 previous_vvvxcvxc,
prev_yr_data.prev_6 previous_zxvxvv,
from table1 cs
inner join table2 usr on cs.xxx = usr.zzzzz
inner join table3 emp on emp.xxx = usr.zzzzz
inner join table4 gbst on cs.xxxs = gbst.zzzzz
inner join table5 sp on cs.xxx = sp.zzzzz
inner join table6 st on sp.xxx = st.zzzzz
inner join table7 ol on ol.xxx = cs.zzzzz
inner join table8 el on el.xxx = ol.zzzzz
inner join table9 spt on trim(upper(el.xxxx)) = trim(upper(spt.xxx))
inner join table10 por on
por.xxx = el.xxxx and
por.xxxx = el.xxxx and
por.xxxx = cs.zzzzz
inner join
(select st.x1,
cs.zzzzz case_zzzzz,
cs.x2 prev_4,
sp.zzzzz ,
sp.x3, sp.x4,
spt.zzzzz ,
spt.xxx prev_1, --Old data 1
el.x5 prev_2, --Old data 2
el.x6 prev_3, --Old data 3
por.xxxx prev_5, --Old data 4
el.x7 prev_6 --Old data 5
from table1 cs
inner join table5 sp on cs.xxxx = sp.zzzzz
inner join table6 st on sp.xxxx = st.zzzzz
inner join table7 ol on ol.xxxx = cs.zzzzz
inner join table8 el on el.xxxxx = ol.zzzzz
inner join table9 spt on trim(upper(el.x_part_name)) = trim(upper(spt.x_part_number))
inner join table10 por on
por.xxx = el.xxxx and
por.xxxx = el.xxxx and
por.xxxx = cs.zzzzz
where ol.date_time between add_months(to_date('date_input','mm/dd/yyyy'), -18) and to_date('date_input','mm/dd/yyyy')
) prev_yr_data on
sp.zzzzz = prev_yr_data.zzzzz and
spt.zzzzz = prev_yr_data.zzzzzz
where ol.date_time >= to_date('date_input','mm/dd/yyyy') and ol.date_time < ( to_date('date_input','mm/dd/yyyy') + 1 )
答案 0 :(得分:1)
我建议您在引入数据集时添加转换,以便在将来18个月(或您喜欢的任何一个)计算您的日期。然后你可以在Spotfire中进行自我加入,其中[Date] = [18MonthsForward]并引入你想要的相同值列。
在源信息下查看时,实现此目标的步骤如下:
2. Select Insert > Transformations...
Add the transformations:
a. Calculate new column
Name: 18MonthsForward
Expression: DateAdd("month",18,[Date])
3. Select Insert > Columns...
Select 'From Current Analysis'
Source location: Data Table
Automatic update.
Match columns:
Date => 18MonthsForward
Ignore columns:
Date
Select join method: LeftOuterJoin
Treat empty values as equal: False
作为一步一步的指示,你会:
(1)选择插入&gt;&gt;转化
(2)从下拉列表中选择计算新列
(3)输入表达式:DateAdd(“month”,18,[Date])并根据您的喜好命名
(4)选择插入&gt;&gt;列
(5)从当前数据中选择并选择当前数据表
(6)加入日期和新计算的18个月前进日期栏
(7)选择您的值列作为新列
附加在数据结果数据表的图像中。 18 months prior value