Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
Hope all are doing good
How to the achieve the below average in the Qlik sense scripting.Please find the below table
metric | JAN | FEB | MAR | APR | MAY | JUN | JUL | AUG | SEP | OCT | NOV | DEC |
Goal/Std | 90% | 90% | 90% | 90% | 90% | 90% | 90% | 90% | 90% | 90% | 90% | 90% |
AVG | 81% | 92% | 107% | 100% | 90% | 73% | ||||||
Forecast | 55% | 55% | 55% | 55% | 55% | 55% | 60% | 70% | 75% | 80% | 85% | 90% |
Actual | 45% | 50% | 59% | 55% | 50% | 40% | ||||||
Submitted | 7% | 22% | 51% | 47% | 42% | 14% | ||||||
Approved | 85% | 86% | 83% | 77% | 67% | 66% | ||||||
Success | 42% | 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
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?
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
Hi @morgankejerhag ,
Please find the below sample data
Metric | User | Month | Target |
Submitted | A | Jan | 7% |
Submitted | A | Feb | 45% |
Submitted | A | Mar | 34% |
Submitted | A | Apr | 13% |
Submitted | A | May | 12% |
Submitted | A | Jun | 67% |
Submitted | A | Jul | 89% |
Submitted | A | Aug | 5% |
Submitted | A | Sep | 15% |
Submitted | A | Oct | |
Submitted | A | Nov | |
Submitted | A | Dec | |
Submitted | B | Jan | 17% |
Submitted | B | Feb | 46% |
Submitted | B | Mar | 30% |
Submitted | B | Apr | 23% |
Submitted | B | May | 2% |
Submitted | B | Jun | 61% |
Submitted | B | Jul | 82% |
Submitted | B | Aug | 15% |
Submitted | B | Sep | 23% |
Submitted | B | Oct | |
Submitted | B | Nov | |
Submitted | B | Dec | |
Approved | A | Jan | 72% |
Approved | A | Feb | 41% |
Approved | A | Mar | 35% |
Approved | A | Apr | 10% |
Approved | A | May | 11% |
Approved | A | Jun | 36% |
Approved | A | Jul | 29% |
Approved | A | Aug | 10% |
Approved | A | Sep | 7% |
Approved | A | Oct | |
Approved | A | Nov | |
Approved | A | Dec | |
Approved | B | Jan | 3% |
Approved | B | Feb | 9% |
Approved | B | Mar | 45% |
Approved | B | Apr | 68% |
Approved | B | May | 92% |
Approved | B | Jun | 18% |
Approved | B | Jul | 28% |
Approved | B | Aug | 48% |
Approved | B | Sep | 71% |
Approved | B | Oct | |
Approved | B | Nov | |
Approved | B | Dec | |
Success | A | Jan | 13% |
Success | A | Feb | 23% |
Success | A | Mar | 33% |
Success | A | Apr | 43% |
Success | A | May | 53% |
Success | A | Jun | 63% |
Success | A | Jul | 73% |
Success | A | Aug | 83% |
Success | A | Sep | 93% |
Success | A | Oct | |
Success | A | Nov | |
Success | A | Dec | |
Success | B | Jan | 33% |
Success | B | Feb | 43% |
Success | B | Mar | 56% |
Success | B | Apr | 66% |
Success | B | May | 76% |
Success | B | Jun | 86% |
Success | B | Jul | 96% |
Success | B | Aug | 14% |
Success | B | Sep | 25% |
Success | B | Oct | |
Success | B | Nov | |
Success | B | Dec |
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
Metric | User | Month | Target |
Forecast | A | Jan | 45% |
Forecast | A | Feb | 55% |
Forecast | A | Mar | 55% |
Forecast | A | Apr | 66% |
Forecast | A | May | 75% |
Forecast | A | Jun | 80% |
Forecast | A | Jul | 83% |
Forecast | A | Aug | 84% |
Forecast | A | Sep | 90% |
Forecast | A | Oct | |
Forecast | A | Nov | |
Forecast | A | Dec | |
Forecast | B | Jan | 45% |
Forecast | B | Feb | 55% |
Forecast | B | Mar | 55% |
Forecast | B | Apr | 66% |
Forecast | B | May | 75% |
Forecast | B | Jun | 80% |
Forecast | B | Jul | 83% |
Forecast | B | Aug | 84% |
Forecast | B | Sep | 90% |
Forecast | B | Oct | |
Forecast | B | Nov | |
Forecast | B | Dec |
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
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?