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

Announcements
Posting on Qlik Community is temporarily paused for some users. Thank you for patience and we'll update you soon!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Class function with variable

I am trying to use the class funtion to count the number of purchases in different brackets. I have written the following in the calculated dimension

=class(PurchaseValue,vWidth,'Purchase Size')

The problem i have is that i just can't take the purchase value direct from the data source as i need to exclude a few entries to get the correct number. To do this i have written the below variable

vpurchase = Reregistration={No},Switch={No}

This variable works but i am stuck as to how i encorporate the variable into the class function.

I have tried the below but it doesn't work can someone help?

=class((vpurchase)PurchaseValue,vWidth,'Purchase Size')



Labels (1)
2 Replies
johnw
Champion III
Champion III

I think this?

=class(aggr(only({<Reregistration={'No'},Switch={'No'}>} PurchaseValue),PurchaseValue),vWidth,'Purchase Size')

Or if you really want to use your variable, probably this?

=class(aggr(only({<$(vpurchase)>} PurchaseValue),PurchaseValue),vWidth,'Purchase Size')

johnw
Champion III
Champion III

Though it might be easier, and would likely run faster, if you create a "No Reregistration No Switch Purchase Value" field, whatever you want to call it.

if(Reregestration='No' and Switch='No',PurchaseValue) as "No Reregistration No Switch Purchase Value"

=class("No Reregistration No Switch Purchase Value",vWidth,'Purchase Size')