Domanda

I am currently using the following calculated field in a Qlikview pivot table.

=if([Event Type] = 'PO',date(MonthStart([EvtDt.Date Code]-15), 'YYYY-MMM'),if([Event Type]   = 'WO',date(MonthStart([EvtDt.Date Code]-50), 'YYYY-MMM'), if([Event Type] = 'BFT PLAN',date(MonthStart([EvtDt.Date Code]), 'YYYY-MMM'))))

Is it possible to pre-calculate this field, perhaps in a LOAD script, so that the field in the pivot table is simply the date value?

È stato utile?

Soluzione

Pre calculating this in the load script would be recommended approach to improve UI performance on larger data volumes, and it also improves maintainability in that you can reuse the field throughout your UI without having the logic stored in multiple places (i.e. on multiple charts).

Without seeing your data structures it is difficult to give you the exact structure, however, assuming you have both fields available in an in memory table during the load, you should just be able to extend your load script to include the calculation as an additional field:

LOAD 
    *
    ,if([Event Type] = 'PO',date(MonthStart([EvtDt.Date Code]-15), 'YYYY-MMM'),if([Event Type]   = 'WO',date(MonthStart([EvtDt.Date Code]-50), 'YYYY-MMM'), if([Event Type] = 'BFT PLAN',date(MonthStart([EvtDt.Date Code]), 'YYYY-MMM')))) as [My New Field]
INLINE [
    Event Type,EvtDt.Date Code,Value
    PO,01/01/2013,1234
    WO,01/01/2013,1234
    BFT PLAN,01/01/2013,1234
];
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top