Create the table in 1 block. deselect the show if empty filter. Create a report level filter for userresponse of your table/chart prompt equal to table.
Create the chart in another block. Deselect the show if empty filter. Create a report level filter for userresponse of your table/chart prompt equal to chart.
You will have a prompt which asks for the Chart / Table option. Now this is a dummy prompt as it doesnt modify the sql query in any way, so you could code something like this :-
TABLE.COL != @Prompt(‘Choose View Mode:’,‘A’,{‘Chart’,‘Table’},MONO,CONSTRAINED,{‘Table’},Not_persistent,USER:0)
(this will always be true- so will not affect results of your query)
Use the variable editor to create a variable which captures the user response of the prompt for Choose View Mode.
Create the table by dragging your fields.
Use the filter pane - theres an icon on the menu to show/hide the filter pane. Select the table. Drag the user resonse variable and create the filter for userresponse= “Table” for the table. This means the table will be shown only if the value for the prompt is Table.
Run the report by selecting Chart as your prompt value. Now you will get a blank report as the filter condition is not satisfied.
Now create the chart. Create a filter for userresponse for the prompt being Chart and apply it to the chart block. Now it will be shown only if the prompt value is Chart.
So there it is, based on filters only 1 of the two will be shown at a time. Hope this makes sense. We have actually implemented this in my project though not with a table and a chart, but 2 different tables.
I forgot to mention that the Show If Empty property for the chart and table should be unchecked- thats how it disappears whenever the filter condition is not satisified.