10 Replies Latest reply: Apr 3, 2017 5:23 PM by Craig Sutton RSS

    Trouble with a variable that evaluates to text

    Lucas Westmaas



      I am attempting to insert into a set expression a string value created by a variable that uses a series of if statements based on current selections. I have verified that the variable is properly returning the string, but for some reason I can't then use the string value in a set expression. This is particularly confusing because I have used a variable in set expression before with no issue; however, that variable was an actual string as opposed to an expression that evaluated to a string.


      Here is a simplified example of what I'm trying to do. The variable definition is something like:

      let clothing = if(count(distinct body_part)=1,if(body_part='Feet','Shoes',if(body_part='Head','Hat')))


      If I insert a text box and insert a measure:


      Then select Feet, the box correct displays Shoes (and same for Head).


      However, when I use the variable as part of a set expression, nothing is returned. For example, if I write:

      count({<[Clothing]={$(clothing)}>} distinct Color)

      Nothing is returned.


      I've tried a number of adjustments and I'm almost positive the issue is with the variable being evaluated from expression. For example, if I write the actual string in:

      count({<[Clothing]={Shoes}>} distinct Color)

      it evaluates correctly, and if I set the variable to a string rather than an expression:

      set clothing = 'Shoes'

      then it also evaluates correctly.


      I've tried a number of adjustments, e.g. using text() or putting the variable in quotes, but nothing has worked. Can anyone help?