Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Highlighted
hamy_IT_Dev
New Contributor II

How to add total of a column in straight table as sum and also average?

How to add total of a column in straight table as sum and also average?
I have 4 dimensions and 3 expressions in straight table.
Dimension1: city
Dimension2: Age
Dimension3: Value1
Dimension4: Value2
expression1: $(variable1)*dim3
expression2: $(variable1)*dim4
expression1: ($(variable1)*dim3 + $(variable1)*dim4)/2

and Age range : (1-5 , 6-10 , 10-15 , 16 - 20)

I need tatal of expression :
if age range just was selected "1-5" Then Total = sum of expression1
but
if age range was selected more than 1 range ("1-5 "and "6-10") Then Total = (Sum(expression1) group by age + Sum(expression1) group by age) / 2

3 Replies

Re: How to add total of a column in straight table as sum and also average?

Did you attempt any?

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)
hamy_IT_Dev
New Contributor II

Re: How to add total of a column in straight table as sum and also average?

Hi Loveisfail

Yes, I tried

I'm not sure which expression I have to use

Thanks

Re: How to add total of a column in straight table as sum and also average?

Try this - This is just an idea because we don't have any data. If you supply any file to work we can better than simple.

If(Age='1-5', Sum(Aggr($(variable1)*dim3, Age)),
If(Match(Age, '1-5', '6-10'), (Sum(Aggr($(variable1)*dim3, Age))+Sum(Aggr(($(variable1)*dim3 + $(variable1)*dim4), Age))/2))

Or

If(Age='1-5', Sum(Aggr($(variable1)*dim3, Age)),
If(Match(Age, '1-5', '6-10'), (Sum(Aggr($(variable1)*dim3, Age))+Sum(Aggr(($(variable1)*dim3 + $(variable1)*dim4), Age))/Count(Age))) // If You want 2 as Dynamic based on Age selection.

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)