SSRS Default parameter based on the data with limitations

Navinkumar Kanagaraj 86 Reputation points
2022-04-13T07:30:31.03+00:00

Hai, here in ssrs report, i have a cascading parameter, which is working fine.

Now I am in need to bring the particular items to default parameters.

For Instances,
I have a parameter named Category, where values are 'Vegetables and fruits'. I selected fruits.
a parameter named Subcategory is there, and the available values are 'Apple, Orange, Grapes, kiwi'.
what exactly I need is, After selecting category as Fruits, in subcategory is 'Apple, Orange' is available in the dataset, that 'Apple, Orange'alone should be shown in default values, If Orange alone is there, default is Orange, If apple alone is there, default is apple.

if neither Apple nor Orange is there, then default should be Grapes, kiwi

SQL for subcategory: SELECT DISTINCT FRUITS FROM TBL.FRUITS WHERE CATEGORY in (@CATEGORY)

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,813 questions
{count} votes

Accepted answer
  1. Joyzhao-MSFT 15,566 Reputation points
    2022-04-13T11:03:18.523+00:00

    Hi @Navinkumar Kanagaraj ,
    I assume the dataset query for parameter Subcategory is from database table [TableC]

    CREATE TABLE TABLEC  
    (CATEGORY VARCHAR(20),  
    NAME VARCHAR(20)) DELETE FROM TABLEC  
    INSERT INTO TABLEC  
    SELECT 'FRUIT','GRAPE'  
    UNION ALL  
    SELECT 'FRUIT','XXX'  
    
    SELECT * FROM TABLEC  
    

    192751-image.png

    The query used for the dataset is as follows:

    declare @hasappleororange int  
      
    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)  
    

    Preview:
    192737-image.png

    And always keep refreshing in the Parameter Properties:

    192639-image.png

    Best Regards,
    Joy


    If the answer is the right solution, please click "Accept Answer" and kindly 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.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful