Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

pivot with range date diff

hi i have a big big problem..

i have a table for example

NUMORDINE

DATE1

DATE2

DATE3

DATE3

i want create a pivot with range date diff

range diff ->1234
count distinct NUMORD where DATE1-DATE2 ->5025
count distinct NUMORD where DATE2-DATE3 ->6136

but is possible ?

for only row was simple,

i used for dimension

if (

        Aggr(DISTINCT DATE1,NUMORDINE)>0 and Aggr(DISTINCT DATE2,NUMORDINE)>0

        ,

        (

        Aggr(DISTINCT Interval(

                         date(date#(DATE2,'YYYYMMDD'),'YYYYMMDD')

                         - date(date#(DATE1,'YYYYMMDD'),'YYYYMMDD'),'d'),

          NUMORDINE)

        )

    )

and for expression

count(DISTINCT NUMORDINE)

but now ? is impossible !!

4 Replies
hic
Former Employee
Former Employee

I would already in the script define fields with the differences:

     date#(DATE2,'YYYYMMDD') - date#(DATE1,'YYYYMMDD') as Difference12    

     date#(DATE3,'YYYYMMDD') - date#(DATE2,'YYYYMMDD') as Difference23

Then you can use these fields as dimensions. No Aggr() needed.

HIC

Not applicable
Author

yes but i cant use in script..

beacuse i have a slidebar with range date value and my boss don't want reload data any change on sidebar !!!

hic
Former Employee
Former Employee

Then try

     Aggr(

          If( Only(Date#(DATE2,'YYYYMMDD')-Date#(DATE1,'YYYYMMDD')) > 0,

               Only(Date#(DATE2,'YYYYMMDD')-Date#(DATE1,'YYYYMMDD'))

               ),

          NUMORDINE)

But I don't like using interpretation functions in the UI... They should be in the script.

HIC

Not applicable
Author

tx for reply but this don't resolve my problem..

i need more than 1 diff !

i need Difference12 and Difference24 in one table pivot wtih range number as dimension !!