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

How can i get average of two deviation columns

Hi Team,

Below is the data scenarios. Could you please guide me how can i achieve this average deviation.

  

BrandRecommendedDateActualApplicationDate
Product 12/6/201712/17/2016
Product 14/6/20174/1/2017
Product 12/28/20171/10/2017
Product 14/19/20171/25/2017
Product 22/18/20172/19/2017
Product 22/21/20172/21/2017
Product 28/4/20171/19/2017
Product 24/8/20172/1/2017
Product 31/18/20171/24/2017
Product 34/15/20174/26/2017
Product 34/11/20163/8/2018
Product 45/9/20175/10/2017
Product 45/9/20175/10/2017
Product 45/6/20175/11/2017
Product 45/6/20175/11/2017

Deviation (in days) = Avg. (Actual Application Date – Recommended Date) of each Product

Means, Avg deviation in days of Product 1, Product 2, Product 3 and Product 4.

Thanks You

Ipsita

7 Replies
arvind_patil
Partner - Specialist III
Partner - Specialist III

Hi Ipsita,

use below code :

=(num(Actual Application Date) – num(Recommended Date)) /Count(Product)


Thanks,

Arvind Patil

sunny_talwar

Where do you need to calculate this? in a text box object or a chart with Product as dimension?

Anonymous
Not applicable

Try these

Option 1: Deviation as a measure

    Move the calculation to the data load script; add ActualApplicationDate - RecommendedDate as Deviation to the script then use the deviation field in charts.

Option 2: Deviation as a dimension

    Add =ActualApplicationDate - RecommendedDate to desired chart

See attached qvf example

Ipsita
Partner - Contributor
Partner - Contributor
Author

I need chart with product as dimension.

dosage.PNG

Ipsita
Partner - Contributor
Partner - Contributor
Author

Thanks Arvind for you reply. However, this expression is not working for me.

Ipsita
Partner - Contributor
Partner - Contributor
Author

Thanks Ugonna for sharing the qvf. But I have one question here, I am using SQL DB table from data manager so is it possible to load data again from script?? Because as of now data for ActualApplicationDate and RecommendedDate is coming from Data Manger SQL DB loaded tables. Shall I again load the table from script.

Anonymous
Not applicable

Hi Ipsita - For the scenario described, you could add the syntax as a preceding load to the script. The updated syntax will look something like this;

Data:

Load *,

ActualApplicationDate - RecommendedDate as Deviation;

Load

Brand,

RecommendedDate,

ActualApplicationDate;

SQL Select

Brand,

RecommendedDate,

ActualApplicationDate

FROM SQL.dbo.tablename;