Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Andrei_Faibich
Contributor III
Contributor III

Assign a SET expression to a variable

I want to create a button to change a variable's value. The values are SET expressions I want to be changed in my measure when I press the button.  I want to implement the logic for the button if(Variable=1,2,1). 

My measure is:

=count({$(Variable)}DISTINCT If(IsNull(wcOrderParentId), @OrderId, wcOrderParentId))

My SET expressions I want to be changed are:

<[Order date] = {'Shipping date'}>

<Order date] = {'Request date'}, wcOrderShipped =- {'NULL'}>

But I have Error for my expressions all the time. I experimented with quoting but no result.

Maybe sombody can help me to find a solution?

 

Labels (3)
2 Solutions

Accepted Solutions
Digvijay_Singh

Check this sample app, I tried to build something like you need.

View solution in original post

Andrei_Faibich
Contributor III
Contributor III
Author

Thank you   so much. This is exactly that I looked for!

I will just highlight your contribution.

=count({<$(=$(Selection ))>}OrderId)

 Selection = if(Variable = 1, SET1, SET2)

SET1 =  [Order date] = {'Shipping date'}

SET2 = [Order date] = {'Request date'}, wcOrderShipped =- {'NULL'}

Variable = 1

if(Variable=1,2,1) // Expression for the Button

View solution in original post

5 Replies
deepanshuSh
Creator III
Creator III

Hi Andrei, Could you please elaborate more on your requirement? Based on what I could understand is that you want the variable value to change when clicked on the button? also, what exactly do you need to be changed in your set expression, can you showcase like before and after?

 

=count({$(Variable)}DISTINCT If(IsNull(wcOrderParentId), @OrderId, wcOrderParentId))

Trial and error is the key to get unexpected results.
Andrei_Faibich
Contributor III
Contributor III
Author

Hi, Thanks for the prompt reply.

Let's simplify. I need this expression

=count({<[Order date] = {'Shipping date'}>} OrderId)

to be replaced by this

=count({<Order date] = {'Request date'}, wcOrderShipped =- {'NULL'}>} OrderId).

But to replace one expression by another is easy. The issue is I have several charts with different formulas and in each Set expression

{<[Order date] = {'Shipping date'}>}

should be replased by this

{<Order date] = {'Request date'}, wcOrderShipped =- {'NULL'}>}

 

deepanshuSh
Creator III
Creator III

I have not tried it myself, but what you can do is create a list of values (inline load) and corresponding name to it, after that put that list into the filter pane. Then create a variable with function getfieldselections and put that variable into your set analysis. 

Trial and error is the key to get unexpected results.
Digvijay_Singh

Check this sample app, I tried to build something like you need.

Andrei_Faibich
Contributor III
Contributor III
Author

Thank you   so much. This is exactly that I looked for!

I will just highlight your contribution.

=count({<$(=$(Selection ))>}OrderId)

 Selection = if(Variable = 1, SET1, SET2)

SET1 =  [Order date] = {'Shipping date'}

SET2 = [Order date] = {'Request date'}, wcOrderShipped =- {'NULL'}

Variable = 1

if(Variable=1,2,1) // Expression for the Button