Skip to main content
Announcements
Accelerate Your Success: Fuel your data and AI journey with the right services, delivered by our experts. Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
kumar2
Contributor III
Contributor III

How do average

Hi,

 

Hope all are doing good

How to the achieve the below average in the Qlik sense scripting.Please find the below table

 

metricJANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC
Goal/Std90%90%90%90%90%90%90%90%90%90%90%90%
AVG81%92%107%100%90%73%      
Forecast55%55%55%55%55%55%60%70%75%80%85%90%
Actual 45%50%59%55%50%40%      
Submitted7%22%51%47%42%14%      
Approved85%86%83%77%67%66%      
Success42%43%43%41%40%40%      

 

I have data for three types  Submitted,Approved and Success in the one Table and other table i have Forecast data as well 

based on this i want to calculate the Actual and AVG

the formula for the Actual --> Average  (Submitted,Approved,Success) i want this column should be available in data model

Formula for  AVG -->Actual/Forecast i want this column should also be available in data model.

 

Thanks,

Chetan

1 Solution

Accepted Solutions
morgankejerhag
Partner - Creator III
Partner - Creator III

You can make a chart expression like:

avg({<Metric={Submitted,Approved,Success}>} Target)

That takes the average of the Submitted, Approved and Success rows. I don't see how you will get your first example table though (with metrics as a first column). What should for example Submitted show when there are several users in the data? Average again?

View solution in original post

3 Replies
morgankejerhag
Partner - Creator III
Partner - Creator III

Can you upload an example of your data (can be faked of course)? It is not really clear how you want to calculate either. In general, you are looking for a pivot table with "metric" column as separate expressions. What do you mean by "Actual --> Average  (Submitted,Approved,Success)"?

Morgan Kejerhag
Senior Business Intelligence Consultant
Drake Analytics, Sweden

kumar2
Contributor III
Contributor III
Author

Hi @morgankejerhag ,

 

Please find the below sample data 

MetricUserMonthTarget
SubmittedAJan7%
SubmittedAFeb45%
SubmittedAMar34%
SubmittedAApr13%
SubmittedAMay12%
SubmittedAJun67%
SubmittedAJul89%
SubmittedAAug5%
SubmittedASep15%
SubmittedAOct 
SubmittedANov 
SubmittedADec 
SubmittedBJan17%
SubmittedBFeb46%
SubmittedBMar30%
SubmittedBApr23%
SubmittedBMay2%
SubmittedBJun61%
SubmittedBJul82%
SubmittedBAug15%
SubmittedBSep23%
SubmittedBOct 
SubmittedBNov 
SubmittedBDec 
ApprovedAJan72%
ApprovedAFeb41%
ApprovedAMar35%
ApprovedAApr10%
ApprovedAMay11%
ApprovedAJun36%
ApprovedAJul29%
ApprovedAAug10%
ApprovedASep7%
ApprovedAOct 
ApprovedANov 
ApprovedADec 
ApprovedBJan3%
ApprovedBFeb9%
ApprovedBMar45%
ApprovedBApr68%
ApprovedBMay92%
ApprovedBJun18%
ApprovedBJul28%
ApprovedBAug48%
ApprovedBSep71%
ApprovedBOct 
ApprovedBNov 
ApprovedBDec 
SuccessAJan13%
SuccessAFeb23%
SuccessAMar33%
SuccessAApr43%
SuccessAMay53%
SuccessAJun63%
SuccessAJul73%
SuccessAAug83%
SuccessASep93%
SuccessAOct 
SuccessANov 
SuccessADec 
SuccessBJan33%
SuccessBFeb43%
SuccessBMar56%
SuccessBApr66%
SuccessBMay76%
SuccessBJun86%
SuccessBJul96%
SuccessBAug14%
SuccessBSep25%
SuccessBOct 
SuccessBNov 
SuccessBDec 

 

The Formula for actual is it calculated based on average of three types in the above table

 

For example

If the "User A" want to see his "actual" then the formula for the Month "Jan" it should take all the targets from A on Month JAN i.e., "(7%+72%+13%)/3=30.7%" is the Actual for the "User A" on the Month "Jan".

 

and there is another table for the forecast please find the below sample data for the forecast as well

MetricUserMonthTarget
ForecastAJan45%
ForecastAFeb55%
ForecastAMar55%
ForecastAApr66%
ForecastAMay75%
ForecastAJun80%
ForecastAJul83%
ForecastAAug84%
ForecastASep90%
ForecastAOct 
ForecastANov 
ForecastADec 
ForecastBJan45%
ForecastBFeb55%
ForecastBMar55%
ForecastBApr66%
ForecastBMay75%
ForecastBJun80%
ForecastBJul83%
ForecastBAug84%
ForecastBSep90%
ForecastBOct 
ForecastBNov 
ForecastBDec 

 

Based on the Actuals which we have calculated above  with that actuals we need to calculate the AVG

For example on the above we have calculated the Actual for the "User A" for Month "Jan" i.e.,30.7, the same User A has forecast as "45%" for the Month "Jan"  in the above table

Based on this two fields we need to calculate the "AVG"

The formula is AVG=30.7(Actual)/45(Forecast)=68.2%

 

Thanks,

Chetan

morgankejerhag
Partner - Creator III
Partner - Creator III

You can make a chart expression like:

avg({<Metric={Submitted,Approved,Success}>} Target)

That takes the average of the Submitted, Approved and Success rows. I don't see how you will get your first example table though (with metrics as a first column). What should for example Submitted show when there are several users in the data? Average again?