SSRS conditional execution of dataset

做~自己de王妃 提交于 2019-12-24 09:41:31

问题


I have two different datasets in SSRS report which gives different number of output fields.I have used this two data set into two different tables in report.

1) One table will display output at a time in execution based on condition.

Actually while running the report two datasets are executing the SP and it takes more time to display the output.

Requirement: I need to execute the one dataset SP at time based on condition.Other Dataset SP should not Execute.

Example: Dataset1 executes Sp1 Dataset2 executes Sp2

Table1 uses Sp1 Table2 uses Sp2

Normally while executing report Table1 will display output(Based on default parameter selection)

But SP1 and SP2 are executing on same time.so report takes more time to display output.

I need to execute 1 SP at a time based on condition.so that other dataset SP will not execute.


回答1:


Step1: First Create Dummy SP for Dataset .That SP should have same input parameters and same output fields as original SP1 but gives zero output rows.Do the same for SP2 for Dataset 2

Step2: In Dataset properties select StoredProcedure Icon and in Fx column add below code

=IIF(Parameters!ManagerID.Value= -1,"SP1","DummySP")

Note: DummySP created should be same like SP1 Do the same for Dataset 2..and this works.




回答2:


You must control the visibility of tablix depends on the received parameter, in additional you can create parameters on both queries to control where execution to avoid the execution, like

Where @Condition = 1 AND ( Your WHERE )



回答3:


As for that sack of performance, you don't want to run other SP at all, in this case, as per my experience, the best way is to modify your stored procs to add a new parameter based on what you are deciding what data set to call (means what data to pull).

So that, if the parameter says that the specific SP is not required, don't run the code in SP using IF-ELSE combo and return blank single row.

And then, on top of that, you can hide or show your tablix.

Hope that makes sense?

And if the column count and data types are same, you can always use an expression to decide what stored-proc to call.



来源:https://stackoverflow.com/questions/45351879/ssrs-conditional-execution-of-dataset

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!