简体   繁体   中英

Cross table in Spotfire

*UPDATE based on ksp's answer (thank you very much for that, it was almost what I was looking for.)

Can somebody help me with the following problem.

Given the data table:

Key     Rec     Period  DOW    Category Value 
Key1    Rec1    Period1 dow1   KPIa     x1    
Key1    Rec2    Period1 dow1   KPIb     z1
Key1    Rec3    Period2 dow1   KPIa     y1  
Key2    Rec4    Period1 dow1   KPIa     x1      
Key2    Rec5    Period1 dow1   KPIb     z1
Key2    Rec6    Period2 dow1   KPIa     y1  
Key1    Rec7    Period1 dow2   KPIa     x2      
Key1    Rec8    Period1 dow2   KPIb     z2
Key1    Rec9    Period2 dow2   KPIa     y2  
Key2    Rec10   Period1 dow2   KPIa     x2      
Key2    Rec11   Period1 dow2   KPIb     z2
Key2    Rec12   Period2 dow2   KPIa     y2
Key1    Rec13   Period1 dow1   Delta    d1
Key1    Rec14   Period1 dow2   Delta    d2
Key2    Rec15   Period1 dow1   Delta    d3
Key2    Rec16   Period1 dow2   Delta    d4

In Spotfire, it is possible to create the following cross table:

              Avg(KPIa)          Avg(KPIb)      Delta 
        Period1     Period2      Period1       Period1                 
       dow1 dow2   dow1 dow2    dow1 dow2     dow1  dow2       
Key1    x1   x2     y1   y2      z1   z2      d1    d2
Key2    x1          y1   y2      z1   z2      d3    d4

Now there is something I would want to change in this cross table but I can't manage to figure out how:

Delta is a column which is only valid for Period1. Is it possible to apply the extra Period and DOW level only to certain columns of the cross table?

So what I want is:

              Avg(KPIa)          Avg(KPIb)       Delta 
        Period1     Period2      Period1         
       dow1 dow2   dow1 dow2    dow1 dow2    
Key1    x1   x2     y1   y2      z1   z2      (d1 + d2) / 2 
Key2    x1          y1   y2      z1   z2      (d3 + d4) / 2 

And when the dow2 is filtered out:

              Avg(KPIa)         Avg(KPIb)        Delta 
        Period1     Period2      Period1         
         dow1        dow1         dow1     
Key1      x1          y1           z1             d1
Key2      x1          y1           z1             d3    

Thanks in advance.

@ user6076025 - Please check this solution and let me know if this helps.

I have considered X as 1, Y as 2 and Z as 3 for computation purpose.

I have unpivoted your data which is there in the first screenshot of your post and then created a cross table from the unpivoted data.

Attached are the screenshots for your reference.

关键数据

来自未透视数据的交叉表

@ user6076025 - I have assigned values to 'dummy value' column in your table for computation purpose and added a calculated column 'new delta' which will average d1,d2 and d3,d4.

Here is the formula: 计算列公式

Now, I have created a cross table from this data. Below are the screenshots of the table and cross table.

新解决方案 Please let me know if this helps.

Regarding the Dow issue, I would place a Drop-down list in a text area with Fixed Value options

Display Name : 'Include Dow2' Value: 0 Display Name : 'Exclude Dow2' Value: 1

Which would have a script for on-change that would do the following:

if Document.Properties["udDowChoice"] == '0':
    Document.Properties["PivotString"] = '<[Category] NEST [Period] NEST [DOW]>'
else:
    Document.Properties["PivotString"] = '<[Category] NEST [Period]>'

Then in the Custom Expression for the Horizontal Axes, you make it equal ${PivotString}

And Limit Data Using Expression

If(${udDow} = 0, 1=1, [DOW] <> 'dow2')

To avoid potential confusion from the users, I also recommend hiding the DOW filter from the Filtering Scheme.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM