【问题标题】:Need to Create calculated columns from input date -18 months in Spotfire for the actual columns需要在 Spotfire 中为实际列从输入日期 -18 个月创建计算列
【发布时间】:2016-07-13 12:47:20
【问题描述】:

我需要创建一个报告,其中每一列都会有一个前一列,该列将给出从作为输入的日期起 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 )

【问题讨论】:

  • 能分享一下数据集吗
  • 给我一些时间,将尝试分享一个与实际相似的样本

标签: oracle spotfire


【解决方案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) 选择插入>>转换

(2) 从下拉列表中选择计算新列

(3) 键入表达式:DateAdd("month",18,[Date]) 并将其命名为您喜欢的任何名称

(4) 选择插入>>列

(5) 从当前数据中选择并选择你当前的数据表

(6) 加入日期和新计算的 18MonthsForward 日期列

(7) 选择您的值列作为新列

附在数据结果数据表的图像中。 18 months prior value

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-01-30
    • 2014-10-31
    • 2016-12-10
    • 2016-11-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多