If you are unable to create a new account, please email support@bspsoftware.com

 

Dynamically selecting different tree prompts based on radio button selection

Started by SRMPDX33, 16 Aug 2020 08:02:01 PM

Previous topic - Next topic

SRMPDX33

I have a requirement to be able to filter a report (filters on report not on a prompt page) by two different tree prompts. Essentially if radio button A is selected a list of members should be displayed in a tree prompt, if radio button B is selected a different list is displayed. I have approached this in the following manner, but have two issues:

I created two conditional blocks, each with a different tree prompt inside. I'm using boolean variables associated with the radio button to decide on which conditional block (and therefore tree prompt) to hide. This is working well with the exception of except these two things:

Issue 1: I need to have option A as default so I set that radio button to default. When the report runs, since the tree prompt for option B is hidden, a prompt page appears with the option B tree prompt. I don't want this, I just want the report to open. If I select no default then the report runs but both conditional blocks are visible until a user selects a radio button (ugly and confusing). I need ot figure out a way of running the report with a default but without a prompt page (maybe setting it after the page loads?)

Issue 2: If a user selects an item(s) in List A, then changes the radio button selection, the A list disappears and the B list appears, but the item(s) they selected in list A is/are still selected. Then they select item(s) in list B and the report is now filtered by both selections. I need to figure out a way to Deselect all in the list when the radio button changes.

Any suggestions on how to fix (or another way to load a single tree prompt with different query results based on a radio button) would be very helpful.




SRMPDX33

In case someone finds this in a search, I resolved issue 1:

Instead of setting a block variable to hide the conditional block I changed it to a style variable, then set Box Type = None when the 'No' option was selected in the boolean variable. This allows the conditional block to be hidden without having the prompt page appear.

seb24c

AFAIK there's no way to deselect prompt values. You could instead use different parameters for list A and list B and then filter the query based on which list was used:

if ( ?p_RadioPrompt? = 'A' ) then ( [whatever] in ?p_ListA? ) else ( [whatever] in ?p_ListB? )

SRMPDX33

I've tried using filters to do this but I haven't figured out the right combo that will work.

When I use 'if' statements in a query I get parsing errors (see https://www.ibm.com/support/pages/using-if-statement-filter-expression)

I've tried something like mentioned in the above link:

((?pAOrB? = 'A') AND ([Options].[OptionA].[Items] in ( ?pOptionAItems?))
OR
((?pAOrB? <> 'A' AND [Options].[OptionB].[Categoies].[Things] in (?pOptionBThings?))

This results in weirdness. When selecting an item in the Option A the filter does nothing. Then I switch to Option B the and select an item in that list the data is filtered. If I leave an item selected in Option B and switch back to Option A the filter in A is working. If either of the filters have nothing selected neither of the filters work. So I have to have one or more items on each filter selected for it to work.   


seb24c

Interesting. I don't usually have trouble with if statements in filters.

In any case, are you sure your parentheses are correct? I only ask because they're not balanced in your example, but that might just be your example and not in your report. Should be like:

(?pAOrB? = 'A' AND [Options].[OptionA].[Items] in ?pOptionAItems?)
OR
(?pAOrB? <> 'A' AND [Options].[OptionB].[Categories].[Things] in ?pOptionBThings?)

SRMPDX33

yeah that was just a bad example with the parenthesis. I've tried it both ways

((?pAOrB? = 'A') AND ([Options].[OptionA].[Items] in ( ?pOptionAItems?)))
OR
((?pAOrB? <> 'A') AND ([Options].[OptionB].[Categoies].[Things] in (?pOptionBThings?)))


(?pAOrB? = 'A' AND [Options].[OptionA].[Items] in ( ?pOptionAItems?))
OR
(?pAOrB? <> 'A' AND [Options].[OptionB].[Categoies].[Things] in (?pOptionBThings?))


I even tried using two different filters each with it's own conditional filter, but this causes the crosstab to disappear when the opposite selection has a filtered item selected

Filter 1
(?pAOrB? = 'A' AND [Options].[OptionA].[Items] in ( ?pOptionAItems?))

Filter 2
(?pAOrB? <> 'A' AND [Options].[OptionB].[Categoies].[Things] in (?pOptionBThings?))

This is really frustrating me.

SRMPDX33

Final Update. With some help from a collegue I got this working. I used two filters like this:


Filter 1
(?pAOrB? = 'A' AND [Options].[OptionA].[Items] in ( ?pOptionAItems?))
OR
(?pAOrB? = 'B' AND 1=1)

Filter 2
(?pAOrB? = 'B' AND [Options].[OptionB].[Categoies].[Things] in (?pOptionBThings?))
OR
(?pAOrB? = 'A' AND 1=1)

This allows the report to ignore the filter when the opposite radio button is selected