Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Highlighted
ilanbaruch
Contributor III

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

Re: aggr with variables

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)

13 Replies

Re: aggr with variables

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
Contributor III

Re: aggr with variables

hi Sunny, behind it there are two variables divided:

Amount$ = mApproved / mTotalAmount

Re: aggr with variables

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

ilanbaruch
Contributor III

Re: aggr with variables

mApproved :

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

mTotalAmount:

sum(AMOUNT)

Re: aggr with variables

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
Contributor III

Re: aggr with variables

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...




Re: aggr with variables

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

ilanbaruch
Contributor III

Re: aggr with variables

expression

Re: aggr with variables

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?