6 Replies Latest reply: Apr 5, 2012 7:22 AM by Jason Michaelides RSS

    Is there an easy way to get the names of fields with selections?

      I know about GetCurrentSelections. What I need, however, is a way to generate an output that only contains the names of the fields in which a selection is currently made. Is there an easy way to achieve this?
      The only idea I have so far is to work with string functions and to somehow reduce the text to only the field names.

        • Is there an easy way to get the names of fields with selections?
          sivaraj seeman

          Hi,

           

          Create a Variable and use getcurrentselections

          U will get only selected values

           

          Sivaraj S

            • Is there an easy way to get the names of fields with selections?

              Thanks for your answer.
              But using a variable does exactly the same as if I just use the function and print the results (e.g. in a textbox).
              I do, however, only need the names of the fields where selections are made. I do not want to also get the selected values.
              For example if I had the fields date, product, country and type and select only a date and a country, if I use GetCurrentSelections() I get
              Date: 10/04/2000
              Country: England
              as an output. What I want to achieve is that I only get
              Date
              Country
              as output.

                • Is there an easy way to get the names of fields with selections?
                  sivaraj seeman

                  Try this..

                  =SubField(GetCurrentSelections(date),':',1)

                    • Is there an easy way to get the names of fields with selections?
                      Jason Michaelides

                      Using a nested Subfield() statement and GetCurrentSelections() I think you can achieve this:

                       

                      =SubField(SubField(GetCurrentSelections(';',':'),';'),':',1)

                       

                      Should work...but will only be good for a chart object or list box, I think. If you want a single text string for a text box or similar then try surrounding the above in a Concat() statement. 

                       

                      Hope this helps,

                       

                      Jason

                        • Re: Is there an easy way to get the names of fields with selections?
                          Stefan Wühl

                          Jason,

                           

                          I believe the 2-parameter version of subfield won't work in the frontend, so your expression will only return one field name, not all selected.

                           

                          Susann,

                           

                          I don't know if there is an easy way of getting just the names of fields with selected values, maybe I am just missing the right QV function. I assume you want to get your results as string in any chart object, not just using the current selections box and disable the visibility of the values, dropdown and clear symbol (in general tab).

                           

                          I could think of two different 'general' approaches to create such a string, i.e. we don't want to hardcode the field names and the check on any selections in them, but we want to be flexible (allowing more fields to be added). If hardcoding is not a problem, I think we can just create an expression like

                           

                          =if(GetSelectedCount(Field1),'Field1 ') & if(GetSelectedCount(Field2),'Field2 ')

                           

                          (adding all fields to the expression).

                          The first general approach might automatically create kind of this expression as a variable in the script, maybe using a loop over all fields or a concat technique (which I haven't fully in mind yet).

                           

                          The second general approach I can think of involves the use of subfield functions again and a technique to create an iterator for the third parameter. We can do it like this:

                           

                          =concat(subfield(subfield(GetCurrentSelections('/'),'/',ValueLoop(1,vFieldNum,1)),':',1),', ',ValueLoop(1,vFieldNum,1))

                           

                          The important thing here is the ValueLoop function, which creates a loop for us when used in an aggregation function like concat, the valueloop function acts as an iterator. vFieldNum is a variable that just holds the number of fields (=count($Field) )

                           

                          See also attached.

                           

                          Hope this helps,

                          Stefan