Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
hamy_IT_Dev
Contributor II
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
Anil_Babu_Samineni

Did you attempt any?

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
hamy_IT_Dev
Contributor II
Contributor II
Author

Hi Loveisfail

Yes, I tried

I'm not sure which expression I have to use

Thanks

Anil_Babu_Samineni

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.

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful