Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
PrashantRupani
Creator
Creator

Minimum of Date By Dimension

Hi, I am new to Qlik Sense 

I have this data set. They want me to display minimum difference of dates by Case Number in a KPI box.

When we choose the case number in a filter then KPI should show the minimum difference. In this case - 14.

How can I achieve this in Expressions?

PrashantRupani_0-1601911389083.png

 

Labels (1)
1 Solution

Accepted Solutions
sunny_talwar

@PrashantRupani try this

Avg(Aggr(Min(Date1 - Date2), [Case Number]))

View solution in original post

6 Replies
Kushal_Chawda

@PrashantRupani  try below

=FirstSortedValue(Date1-Date2, aggr(Date1-Date2,CaseNumber))

PrashantRupani
Creator
Creator
Author

It returned - when I create the expression. I ensured I choose the case number in the filter. But it returns -

sunny_talwar

@PrashantRupani did you try Min(Date1-Date2)

PrashantRupani
Creator
Creator
Author

I tried this expression :  =AGGR(MIN(Date1-Date2),Case Number)

It returns 14 when I choose only one Case Number in the filter but when I try choosing multiple case numbers in the filter, it returns nothing. It shows '-' . I

Say if there was another case number  101 where the minimum difference is 10 

My requirement is to show (14+10)/2  which is 12 ( 2 case number hence divide by 2). I need to return 12 in the KPI Object. 

sunny_talwar

@PrashantRupani try this

Avg(Aggr(Min(Date1 - Date2), [Case Number]))
PrashantRupani
Creator
Creator
Author

That worked. Thanks Sunny