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

Calculated Metric for last two months

Hi,

In Metric 4 (M4) It is the sum of M1, M2 and M3 till the 3rd last month of the selected till date which simple but things gets messy for calculation of last two months. To calculate M4 for last two months it should take the average of M5 last 3rd and 4th month and than add M1+M2+M3. I am stuck on average part and how to show different calculations in same metric.

Service Month3/1/20194/1/20195/1/20196/1/20197/1/20198/1/2019
M1100100100100100100
M275651210105
M31015520105
M4M1+M2+M3M1+M2+M3M1+M2+M3M1+M2+M3AVERAGE(1.20,1.00)+M1+M2+M3AVERAGE(1.20,1.00)+M1+M2+M3
M51.506.501.201.002.902.90
   AVERAGE  

 

Thanks,

Anurag 

Labels (1)
3 Replies
chrismarlow
Specialist II
Specialist II

Hi,

I think the answer to this is going to be different dependent on how your data is structured, so;

Are M1, M2, M3 & M5 columns in your data, or,

Are M1, M2, M3 & M5 values for a 'Metric' column on a table that also has a Value column, e.g.

Service Month, Metric, Value

3/1/2019, M1, 100

3/1/2019, M2, 75

etc.

Cheers,

Chris.

anurag0105
Contributor
Contributor
Author

hi,

 

M1,M2,M3 etc are columns in my data.

 

 

Regards,

Anurag 

chrismarlow
Specialist II
Specialist II

Hi,

Then you should be able to do  something like the following.

First create some variables covering the dates of interest (note my date format is DD/MM/YYYY & you may need to do something so the last date gets calculated);

20190625_1.png

Then you can use an If with TOTAL & some set analysis to only add on the average when you need it (& average the correct two dates);

20190625_2.png

Let me know if I have misunderstood.

Cheers,

Chris.