Parameters in SSRS _ Based on previous parameter

Navinkumar Kanagaraj 86 Reputation points
2022-05-16T15:18:34.683+00:00

https://learn.microsoft.com/en-us/answers/questions/810809/ssrs-default-parameter-based-on-the-data-with-limi.html

hi, In the Below link, we could see that the default parameter is fixed on conditions. But I have a Concern that what if Based on the previous parameter, what if we have no values. then in that case I want to see none available as a result.

Points: 1. I have tried using the IF statement in the Above query using putting the result in the tmp table, but facing error.

SQL Server Reporting Services
SQL Server Reporting Services
A SQL Server technology that supports the creation, management, and delivery of both traditional, paper-oriented reports and interactive, web-based reports.
2,951 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Isabellaz-1451 3,616 Reputation points
    2022-05-17T02:59:04.257+00:00

    Hi @Navinkumar Kanagaraj
    You can try this:

     declare @hasappleororange int  
     declare @hasnovalue int     
       set @hasnovalue =(select count(*)from TABLEC)  
       if(@hasnovalue=0)  
       begin  
         select NAME= null  
    	end  
    	else   
    	begin  
        set @hasappleororange =(select count(*)from TABLEC where NAME in('APPLE','ORANGE'))  
        if (@hasappleororange>=1)  
        SELECT distinct NAME from TABLEC where NAME in('APPLE','ORANGE')  
       
        else  
        SELECT * FROM (VALUES('GRAPE'),('KIWI')) AS p(NAME)  
        end  
    

    when there is no data, result is:

    202631-image.png

    Best Regards,
    Isabella


    If the answer is the right solution, please click "Accept Answer" and upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.