
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?
Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Check this sample app, I tried to build something like you need.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you Digvijay_Singh 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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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))

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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'}>}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Check this sample app, I tried to build something like you need.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you Digvijay_Singh 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
