Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

finding average value

Hi,

I have question like below,

   

NameDateValue
A1/1/2017AM2
A1/1/2017PM4
B1/2/2017AM6
B1/2/2017PM7
C1/3/2017AM5
C1/3/2017PM4
D1/4/2017AM2
D1/4/2017PM

3

from above table I need to find the average value like below table,

    

NameDateValueAvg.Value
A1/1/2017AM21
A1/1/2017PM4-0.5
B1/2/2017AM60.17
B1/2/2017PM7-0.14
C1/3/2017AM51.2
C1/3/2017PM110.545
D1/4/2017AM20.5
D1/4/2017PM3

-0.33

here i applied one formula manually to find the avg value,

By using this below formula to find Avg value's

finding AM Avg Value :

PM-AM\AM---->4-2/2=1

finding PM value:

AM-PM/PM----->2-4/4=-0.5

In qlik it will be possible to find the Avg.Value dynamically. I am looking for expression or script wise to get the Avg.Value dynamically.

Regards,

Yuvaraj

1 Solution

Accepted Solutions
swuehl
MVP
MVP

Looks more like a relative increase / decrease than an average value.

Maybe like

Set DateFormat = 'M/D/YYYY';

LOAD Name, Date as DateOrig, Left(Date,Index(Date,'/',2)+4) as Date, Right(Date,2) as AMPM, Value;

LOAD * INLINE [

Name, Date, Value

A, 1/1/2017AM, 2

A, 1/1/2017PM, 4

B, 1/2/2017AM, 6

B, 1/2/2017PM, 7

C, 1/3/2017AM, 5

C, 1/3/2017PM, 4

D, 1/4/2017AM, 2

D, 1/4/2017PM, 3

];

and then a table chart with Name, DateOrig as dimensions and as expression

=If(AMPM='AM',

  Only({<AMPM = {PM}>} TOTAL<Name,Date> Value) / Only({<AMPM = {AM}>} TOTAL<Name,Date> Value)-1,

  Only({<AMPM = {AM}>} TOTAL<Name,Date> Value) / Only({<AMPM = {PM}>} TOTAL<Name,Date> Value) -1

)

Name DateOrig Value Increase / Decrease
A1/1/2017AM21,00
A1/1/2017PM4-0,50
B1/2/2017AM60,17
B1/2/2017PM7-0,14
C1/3/2017PM40,25
C1/3/2017AM5-0,20
D1/4/2017AM20,50
D1/4/2017PM3-0,33

View solution in original post

2 Replies
swuehl
MVP
MVP

Looks more like a relative increase / decrease than an average value.

Maybe like

Set DateFormat = 'M/D/YYYY';

LOAD Name, Date as DateOrig, Left(Date,Index(Date,'/',2)+4) as Date, Right(Date,2) as AMPM, Value;

LOAD * INLINE [

Name, Date, Value

A, 1/1/2017AM, 2

A, 1/1/2017PM, 4

B, 1/2/2017AM, 6

B, 1/2/2017PM, 7

C, 1/3/2017AM, 5

C, 1/3/2017PM, 4

D, 1/4/2017AM, 2

D, 1/4/2017PM, 3

];

and then a table chart with Name, DateOrig as dimensions and as expression

=If(AMPM='AM',

  Only({<AMPM = {PM}>} TOTAL<Name,Date> Value) / Only({<AMPM = {AM}>} TOTAL<Name,Date> Value)-1,

  Only({<AMPM = {AM}>} TOTAL<Name,Date> Value) / Only({<AMPM = {PM}>} TOTAL<Name,Date> Value) -1

)

Name DateOrig Value Increase / Decrease
A1/1/2017AM21,00
A1/1/2017PM4-0,50
B1/2/2017AM60,17
B1/2/2017PM7-0,14
C1/3/2017PM40,25
C1/3/2017AM5-0,20
D1/4/2017AM20,50
D1/4/2017PM3-0,33
Anonymous
Not applicable
Author

Thanks stefan