Skip to main content
Announcements
See why Qlik is a Leader in the 2024 Gartner® Magic Quadrant™ for Analytics & BI Platforms. Download Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

create variable with set analysis

I want to make a variable with a set analysis where i discriminate on 2 logical.

case:

I want to create variable vItem

Item_number (integer)

Item_active (logical)

Item_dutch (logical)

from the documents and the cases on the community it should be something like:

$({< [Item_number] = {*} - [Item_active] = {"false"}, [Item_dutch] = {"true"} >})

unfortunately this doesn't work.

is there a solution for this case?

1 Solution

Accepted Solutions
petter
Partner - Champion III
Partner - Champion III

The set expression should probably be written like this:

{<[item_number]=,[item_active]={'true'},[item_dutch}={'true'}>}

And it could be put into a variable vItem and used as you see here:

Sum( $(vItem) Price )

View solution in original post

6 Replies
sunny_talwar

Would you be able to share some data with your expected output. Just seeing the fields and expression doesn't provide us with much information.

petter
Partner - Champion III
Partner - Champion III

The set expression should probably be written like this:

{<[item_number]=,[item_active]={'true'},[item_dutch}={'true'}>}

And it could be put into a variable vItem and used as you see here:

Sum( $(vItem) Price )

Not applicable
Author

item_number ; Item_active ; Item_dutch

000001             ;true               ; true

000002             ;true               ; false

000003         ; false         ; true

000004         ; false         ; false

now i want to make a variable vItem where i only have the item_numbers where [Item_active] = true and [Item_dutch] = false (so only [item_number] 000002 is visible).

While typing this i see the reaction from Petter and this one works.

could it be that i used a double quote instead of a single?

petter
Partner - Champion III
Partner - Champion III

Using double quotes is not the problem with your set expression.

But you cannot have a full expression on the left hand side of the equal sign. The one with the minus operator.

On the left hand side you are only allowed to have a field name and then comes either =  -=  +=  /=  or *=.

Not applicable
Author

Petter, Thanks for your reaction.

What I tried with the "minus operator" comes from a document (Fabrice AUNEZ - version 2.1). On page 7/8 the expressions with exceptions are described.

Ex:

All MANUFACTURERs except those whose name begins with ENT

{<MANUFACTURER_LDESC = {"*"} - {"ENT*"}>}

From your answer i understand that this is correct aslong the left hand side isn't a full expression.

petter
Partner - Champion III
Partner - Champion III

Looking closer at your expression I have further remarks.

The allowed syntax for set expressions don't allow for an expression like you have made. There is a difference between Fabrice's expression and yours since you employ the equal sign twice.

On the left hand side of an  =   +=  -=  /= or *=   you are allowed one field name which exist in the data model.

On the right hand side you are allowed an element set or another field but not both. Furthermore you can't do a kind of selection from this field name if you use that.

So my suggestion that seemed to work for you could be modified to be more like yours:

          {< [Item_number] = {"*"}, [Item_active] -={'false'}, [Item_dutch] = {'true'} >}

The double quotation-marks turn the strings into a search expression which will in many cases also work like literal constants which use single quotation-marks as long as you don't use real search expressions.