Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Martina_Kraft
Contributor
Contributor

Set Expression with Filter Variable not working with multiple values

 

Hi,

I have a variable

V_SEL_SEG =if(getfieldselections(Segment)>0,concat(Chr(39) & Replace(getfieldselections(Segment), ',', Chr(39) & ',' & Chr(39)) & Chr(39)))

and - in short - a set expression using this variable:

Sum({<Segment={"$(=$(V_SEL_SEG))"}>}Value).

The above set expression works when a single value is selected in the Segment filter.

But when I select multiple values in the filter the set expression returns only the sum of values of the Segment selected first although the information in the formula editor is showing that three values were selected.

Can anyone please guide me how to fix this expression ?

 

QS_Variable_Filter_not_Working.PNGAppreciate your help !

Thanks,

Martina

1 Solution

Accepted Solutions
marcus_sommer

Your variable-expression isn't quite correct because it adds an extra space in front of each value (it's hard to notice on your screenshots but if you sized them big enough it will be visible).

Beside this what is the aim of adding this condition within the expression? Wouldn't it be easier and better to skip this part as it is (nearly) the same like a normal selection? If you really want to keep this logic you may consider an easier approach with p() like:

Sum({<Segment = p(Segment)>} Value)

- Marcus

View solution in original post

3 Replies
Chanty4u
MVP
MVP

can you try this?

your varibale:   

V_SEL_SEG ='if(getfieldselections(Segment)>0,concat(Chr(39) & Replace(getfieldselections(Segment), ',', Chr(39) & ',' & Chr(39)) & Chr(39)))'

exp: 

Sum({$<Segment={'$(V_SEL_SEG)'}>}Value)

 

marcus_sommer

Your variable-expression isn't quite correct because it adds an extra space in front of each value (it's hard to notice on your screenshots but if you sized them big enough it will be visible).

Beside this what is the aim of adding this condition within the expression? Wouldn't it be easier and better to skip this part as it is (nearly) the same like a normal selection? If you really want to keep this logic you may consider an easier approach with p() like:

Sum({<Segment = p(Segment)>} Value)

- Marcus

Martina_Kraft
Contributor
Contributor
Author

You are right: I changed the value to be replaced from ','  to ', ' (Comma - Space) and now it's working. 

The p(Segment) solution also works, but my intention is to move the diagram to an alternate state - except for filter settings that are done for the Segment field in the original state. That's why it need the variable.

Thank you so much, you saved my day 😀

Martina