Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
shoaibmulla
Contributor
Contributor

Different Averages being calculated

Hi

I have used the duration field in a simple table where duration is being displayed against each record and Totals (Average is being shown).

=IF(
(date([Timeline_Forecasts.Forecast CP1 Date])> date([Timeline_Forecasts.Forecast Project Start])),
date([Timeline_Forecasts.Forecast CP1 Date])- date([Timeline_Forecasts.Forecast Project Start])
)

 

However, If I use a similar formula in a table that groups certain categories the result is completely different. The formula I have used is

=Avg(
IF(
date([Timeline_Forecasts.Forecast CP1 Date])> date([Timeline_Forecasts.Forecast Project Start]),
date([Timeline_Forecasts.Forecast CP1 Date])- date([Timeline_Forecasts.Forecast Project Start])
)
)

The one displayed in the details table is correct average. Would appreciate your help.

Qlik - Average.PNG

 

Labels (1)
3 Replies
sunny_talwar

Can you try this same expression for both the tables and see if this works

=Avg(RangeMax([Timeline_Forecasts.Forecast CP1 Date] - [Timeline_Forecasts.Forecast Project Start], 0))
shoaibmulla
Contributor
Contributor
Author

Hi Sunny

Thank you very much for the response but it didn't work in either of the tables (detailed and summary). In detail table it replaces null values with 0, which makes the average go off. The formula I had used earlier was providing the correct results for detailed table.

Shoaib

shoaibmulla
Contributor
Contributor
Author

I was able to get the correct average by using the following formula for the summary table.

=Avg(
	Aggr(
          (IF(
             (date([Timeline_Forecasts.Forecast CP1 Date])> date([Timeline_Forecasts.Forecast Project Start])),
              date([Timeline_Forecasts.Forecast CP1 Date])- date([Timeline_Forecasts.Forecast Project Start]))),[Server.ProjectName]
             )
     )