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

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
reporting_neu
Creator III
Creator III

Calculate with Min in Dimension

Hi,

I'm calculating the distance of days between two date fields in a dimension.

 

 

[Date1] - [Date2]

 

 

Now I also want to check if the result agrees with the smallest result (MIN).

 

 

if([Date1]-[Date2]=Aggr(Min([Date1]-[Date2],[Part]), 'Flag', null())

 

 

Unfortunately I get no result here (null()). I can't compare the two values.

But why? What am I doing wrong?

Labels (1)
3 Replies
hic
Former Employee
Former Employee

I would create a new field in the script:

Date1 - Date2 as DateDiff,

and then you can use this as dimension, or inside a Min()

HIC

reporting_neu
Creator III
Creator III
Author

Thanks for your answer. Unfortunately I can't use it in the script because a date field is a variable. The date can therefore be changed at any time.

hic
Former Employee
Former Employee

Then you are right to use an Aggr(). Try

Dimension to calculate diff: 

 

Aggr([Date1]-[Date2],[Date1],[Date2])

 

Flag to test for Min:

 

Aggr(If([Date1]-[Date2]=Min(total [Date1]-[Date2]),'Min','Other'),[Date1],[Date2])