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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
ilanbaruch
Specialist
Specialist

aggr with variables

hi all,

is it possible to aggregate from a variable?

tried it like this

=FirstSortedValue(PAYMENT_TYPE, -Aggr($(Amount$), PAYMENT_TYPE))

but didn't retrieve..

any ideas?

advanced thanks

1 Solution

Accepted Solutions
sunny_talwar

Then this should work unless you have duplicates

=FirstSortedValue(PAYMENT_TYPE, -Aggr(Sum(AMOUNT), PAYMENT_TYPE))

or you can do this if you have duplicates and you want to pick one name

=FirstSortedValue(DISTINCT PAYMENT_TYPE, -Aggr(Sum(AMOUNT), PAYMENT_TYPE))

or this if you wish to show all PAYMENT_TYPE separated by commas

=Concat(DISTINCT {<PAYMENT_TYPE = {"=Rank(Sum(AMOUNT)) < 2"}>} PAYMENT_TYPE)

View solution in original post

13 Replies
sunny_talwar

You should be able to. I am guessing that Amount$ is your variable? How do you define it? I mean what is the expression behind it?

ilanbaruch
Specialist
Specialist
Author

hi Sunny, behind it there are two variables divided:

Amount$ = mApproved / mTotalAmount

sunny_talwar

Hahaha and how are those defined? Can you share a sample maybe?

ilanbaruch
Specialist
Specialist
Author

mApproved :

sum({$<STATUS={'Approved'}>}AMOUNT)

mTotalAmount:

sum(AMOUNT)

sunny_talwar

So, can you try to check if this is working or not?

=FirstSortedValue(PAYMENT_TYPE, -Aggr(Sum({<STATUS = {'Approved'}>} AMOUNT)/Sum(AMOUNT), PAYMENT_TYPE))

and if that works, then it is the way you have defined your variables that might be causing an issue. It would be faster if you are able to share a sample, if not, then we will slowly troubleshoot this.

ilanbaruch
Specialist
Specialist
Author

hi,

tried it with the expression but it didn't work.

set the expression in a variable 'vTest' it retrieved the value..

vTest in the aggregate again didn't work...




sunny_talwar

Tried it with expiration? Not sure I understand what you mean?

ilanbaruch
Specialist
Specialist
Author

expression

sunny_talwar

I don't really know what you have except the expression you have shared. Can you share some information as to what exactly are you trying to do? May be a sample?