5 Replies Latest reply: Oct 15, 2013 10:43 AM by David Vasseur RSS

    Fields with selections

    Marie-Sophie Blond

      Hi,

       

      I have a list of field 'Field1', 'Field2', 'Field3', 'Field4', 'Field5'.

      I want to compare this list of fields to current selections in order to generate an output with fields present in my list  in which a selection is currently made.

       

      Does anyone would have an idea to achieve this ?

        • Re: Fields with selections
          Peter Cammaert

          I'm not sure I understand what you're after.

          If you want a dynamic table with expressions that can be selected from a separate list, have a look at the following example.

           

          Peter

          • Re: Fields with selections
            Gysbert Wassenaar

            I don't understand why you can't use a Current Selections Box object. But if you want an alternative have a look at the attached example.

              • Re: Fields with selections
                Marie-Sophie Blond

                Hi,

                 

                Thank you for your response.

                Here are more details on my problem : I have a master calendar with about 100 fields.

                In a table, i have to display the price for the current month, the price for the next month and the price for the previous month.

                My table must be independant from selections on a week, a commercial event, a particular day.

                 

                I currently create dynamically a set analysis with all the fields of my calendar except the month, but in order to ameliorate my formula I would like to have only the calendar fields present in active selections.

                 

                 

                  • Re: Re: Fields with selections
                    Gysbert Wassenaar

                    So, If I understand you correctly you want a string that's a list of the fields in which selections are made?

                     

                    Well, one way is to create a variable per field that returns the field name if there are selections in the field. Then concatenate all those variables into one string. The variables can be generated in the script:

                     

                    SET _vFList ='';

                    FOR i = 0 to NoOfTables()-1;

                    LET vTable = TableName($(i));

                    FOR j = 0 to NoOfFields('$(vTable)')-1;

                      vField=FieldName($(j),'$(vTable)');

                      vVarName=replace('$(vField)',' ','_');

                      SET _v$(vVarName) = =if(getselectedcount([$(vField)]),'$(vField),');

                      SET _vFList = $(_vFList) & _v$(vVarName);

                    NEXT j;

                    NEXT i;

                    LET _vFList = right('$(_vFList)',len('$(_vFList)')-1 );

                     

                    The last variable _vFList should return the list of fields when you dollar-expand it in a sheet object: $(_vFList). See attached example.

                     

                    There may be an easier way, but I haven't found it yet. Maybe a real pro knows how to do this more efficiently.

                      • Re: Fields with selections
                        David Vasseur

                        Hi,

                         

                        I had the same issue and could find a good solution. So I ended in listing all my fields (automatically through variables of course ;-) ) and, to my surprise, the performance was still very good, event with 100 fields.

                         

                        But I'd love to have a proper answer on this too !

                         

                        Regards,

                        David