Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
SkitzN27
Creator
Creator

Average of min(date) with set analysis using dimension

Hi

Here's my data 

Screen Shot 2020-11-10 at 10.44.20 AM.png

The calculation for my Days column is = 'Date 1 - min({<Dimension={'XYZ'}>}Date2)' . Now I want to take an Average(Days) i.e. '(Average(Date 1 - min({<Dimension={'XYZ'}>}Date2)) 'and present it on bar chart with Yr Qtr of Date1 as my dimension.

Dimension: Yr Qtr of Date 1

Expression: Avg(Date 1 - min({<Dimension={'xyz'}>}Date2))

 

For example: The average for 2020 Q1 = (54+33+48)/3 = 45

The average of 2020 Q2 = (145+28)/2 = 86.5

@QFabian @MayilVahanan @rwunderlich 


Sample Data:

Unique NumberPhaseDaysDate1Yr Qtr of Date 1Dimensionmin({<Dimension={'XYZ'}>}Date2)
1Phase 1---xyz01-Oct-2020
2Phase 114529-Jun-20202020 Q2xyz04-Feb-2020
3Phase 15430-Mar-20202020 Q1xyz04-Feb-2020
4Phase 13309-Mar-20202020 Q1xyz04-Feb-2020
5Phase 1---xyz15-Oct-2020
6Phase 1---xyz01-Oct-2020
7Phase 1---xyz01-Oct-2020
8Phase 12804-Jun-20202020 Q2xyz06-May-2020
9Phase 14824-Mar-20202020 Q1xyz04-Feb-2020
1 Solution

Accepted Solutions
MayilVahanan

Hi @SkitzN27 

Try like below

In bar chart.
Avg(Aggr(Date1 - [min({<Dimension={'XYZ'}>}Date2)], [Yr Qtr of Date 1], [Unique Number]))

or
In Straight table
Avg(Total<[Yr Qtr of Date 1]> Aggr(Date1 - [min({<Dimension={'XYZ'}>}Date2)], [Yr Qtr of Date 1], [Unique Number]))

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.

View solution in original post

14 Replies
QFabian
Specialist III
Specialist III

aggr should be inside :

avg(aggr((min({<Dimension={'xyz'}>}date1), xyz) - date2) 

QFabian
MayilVahanan

HI @SkitzN27 
When you are using Date1 & Date2 as dimension, 
min(Date1) always same as Date1 values (dimension).

May be, try like below
Avg(Aggr(Min({<Dimension={'xyz'}>}Total Date1) - Date2, Dimension))
--
Min({<Dimension={'xyz'}>}Total Date1) -- It assign the Min Date for all rows and subtract from Date2 based on Dim and takes avg.

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
SkitzN27
Creator
Creator
Author

Hi guys @MayilVahanan  @QFabian 

None of the solutions seem to be working.
Let me put it in easier words:

Avg(if( Dimension = 'xyz' , min( Date1) -Date2, null()))

Kushal_Chawda

@SkitzN27  try below

= if( Dimension = 'xyz' , min(total <Dimension>Date1)- Date2,null())

Kushal_Chawda

@SkitzN27  or below

= avg(aggr(if( Dimension = 'xyz' , min(total <Dimension>Date1)- Date2,null()),Dimension))

SkitzN27
Creator
Creator
Author

Hi @Kushal_Chawda  I have changed the post, can you look at it again?
I have provided all the data that might be needed

@MayilVahanan  @QFabian 

QFabian
Specialist III
Specialist III

i just did this : avg (total <[Yr Qtr of Date 1]> Days), try it please

QFabian_0-1605024434761.png

 

QFabian
SkitzN27
Creator
Creator
Author

You can't directly put days in your expression.
Days is a calculated column that you get using   'Date 1 - min({<Dimension={'XYZ'}>}Date2)'

So you cant use Avg and Min together

@QFabian 

QFabian
Specialist III
Specialist III

where is Date2?

QFabian