6 Replies Latest reply: May 18, 2009 7:42 PM by Robert Henry RSS

    Help with "Conditional Show"

      I Have a graph that I only want displayed if a certain year is selected. I have this formula in the Show Conditional formula box on the Layout tab

      Year(Date) = Year(Today())

      This works if only one year (the current year) is selected, but if I select the current year and last year. Neither of the graphs show up.

      What can I do to the formula to display the graph if at least one of the selected values for Year is the current year?

        • Help with "Conditional Show"
          npeyroux

          Hi there,

          you can try to use the system function like GetFieldSelections.

          GetFieldSelections(Date) will give you all selected Date.

          you may then try to find the if the year of the maximum date is this year.

          The formula sould look at the following:

          Year(max(GetFieldSelections(Date) ))=year(today())

           

          • Help with "Conditional Show"
            Neil Miller

            I'm not sure if there is an easier way, but this can be accomplished using a macro.

            Set an On Select macro for the Year field. Use something like this:

            SUB Chooser
            set Sello = ActiveDocument.Fields("Year").GetSelectedValues

            ActiveDocument.Variables("vGoodYear").SetContent 0, true

            for i = 0 to Sello.Count - 1
            if Sello.Item(i).text = "2009" then
            ActiveDocument.Variables("vGoodYear").SetContent 1, true
            end if
            next
            END SUB

            Then you can use the variable in the Show expression. This macro is a simplified version of what you would need. You could set the conditional based on the current year, which looks like what you are trying to do.

              • Help with "Conditional Show"

                 

                I'm going to elaborate a little more on my problem.

                I have 3 graphs, one graph I want displayed if one of the selected years is 2009, one for 2008 and the other for 2007.

                @npeyroux, the Max() causes your formula to break when multiple years are selected.

                Also max is out of the question because 2008 falls in between 2009 and 2007 if all three years were selected.

                A macro shouldn't be needed, If I can filter it and have it see the 2008 out of a list within an if then else statement, the same should be possible within an expression. I'd also like to stray away from macros for performance and managability.

                GetFieldSelections() seems to be the best bet, but for some reason Max() is not working together with it. Any other suggestions?