locked
Different default parameter values RRS feed

  • Question

  • Hello,

    I have an SSRS 2012 report with a StartDate and EndDate parameters.

    I have a requirement to have different default values depending on if the end user is viewing the report in the browser (todays date and yesterdays date), versus the start and end date of the previous month if the report is being generated on a schedule and sent as a csv attachment in an email. 

    Is there a way of testing if the SSRS report is running in 'browser mode' or not?

    Any suggestions appreciated.

    mrHh

    Monday, April 13, 2015 9:11 PM

Answers

  • Hi mrHh,

    Per my understanding that you have two date type parameters, you want to change the default values of the two parameters based on if the report is running on the broswer or send as email subscription rendered as CSV report, right?

    What do you mean about "browswer mode", did you mean run the report in report manager, report server or do you mean render the report as MHTML or HTML format?

    Generally we have an build in field "Globals!RenderFormat.IsInteractive", when the report is running on report server ,report manager or render the report as MHTML, HTML, this field will returns the value "True", if you render the report as CSV,excel, PDF and so on, the value will be "false". But this value can't be used in the parameter to dynamic change the values, it can be used in the expression in the report.

    In your scenario, I suggest you add the "Globals!RenderFormat.IsInteractive" in the report to just show the end user if the report is running in "browser mode" or not.

    If I have some misunderstanding, please try to provide more details information about your requirements.

    Regards,
    Vicky Liu

    If you have any feedback on our support, please click here.


    Vicky Liu
    TechNet Community Support


    • Edited by Vicky_Liu Tuesday, April 14, 2015 3:09 AM
    • Proposed as answer by Visakh16MVP Tuesday, April 14, 2015 5:08 AM
    • Marked as answer by Vicky_Liu Tuesday, April 21, 2015 1:21 AM
    Tuesday, April 14, 2015 3:08 AM
  • Hi,

    When I say browser mode I mean accessing the report using IE in report manager.

    Another method I have thought of is that, my company tends to deploy two versions of the report to different folders if they are to be regulary emailed.  I could test the ReportURL property to see which folder the report is in - this will be different depending on on if its the browse-able version or not.

    • Proposed as answer by Vicky_Liu Monday, April 20, 2015 1:15 AM
    • Marked as answer by Vicky_Liu Tuesday, April 21, 2015 1:21 AM
    Tuesday, April 14, 2015 9:26 PM

All replies

  • I think the easiest way to achieve this would be to create separate parameters in the report.  

    Create two hidden parameters for start date and end date which allow null. 

    When the report is run from a subscription set these parameters.  In the stored proc/SQL for the report if these parameters are not null then use them, otherwise if they are null then use the start and end date parameter that the user can see.

    Alternatively - always set both parameters and add another parameter which is hidden which flags which set of parameters should be used.

    I don't think there is a way for the report to know whether it is being run in the browser - but you can tell it via parameter if it is being called from a subscription. 

    HTH

    Cheers


    LucasF

    Tuesday, April 14, 2015 1:11 AM
  • Hi,

    As Lucas mentioned create two parameters startdate and enddate

    StartDate Default expression:-  =DateAdd("d",-1,Today())

    EndDate Default expression:- Today()

    It will fill when you render the report.

    Now for subscription, create data driven subscription and write the SQL as below:-

    select DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE())-1, 0) StartDate,
    DATEADD(MONTH, DATEDIFF(MONTH, -1, GETDATE())-1, -1)EndDate

    Now use above values for the parameters in DataDriven subscription.

    Thanks

    Prasad

    Tuesday, April 14, 2015 1:31 AM
  • Hi mrHh,

    Per my understanding that you have two date type parameters, you want to change the default values of the two parameters based on if the report is running on the broswer or send as email subscription rendered as CSV report, right?

    What do you mean about "browswer mode", did you mean run the report in report manager, report server or do you mean render the report as MHTML or HTML format?

    Generally we have an build in field "Globals!RenderFormat.IsInteractive", when the report is running on report server ,report manager or render the report as MHTML, HTML, this field will returns the value "True", if you render the report as CSV,excel, PDF and so on, the value will be "false". But this value can't be used in the parameter to dynamic change the values, it can be used in the expression in the report.

    In your scenario, I suggest you add the "Globals!RenderFormat.IsInteractive" in the report to just show the end user if the report is running in "browser mode" or not.

    If I have some misunderstanding, please try to provide more details information about your requirements.

    Regards,
    Vicky Liu

    If you have any feedback on our support, please click here.


    Vicky Liu
    TechNet Community Support


    • Edited by Vicky_Liu Tuesday, April 14, 2015 3:09 AM
    • Proposed as answer by Visakh16MVP Tuesday, April 14, 2015 5:08 AM
    • Marked as answer by Vicky_Liu Tuesday, April 21, 2015 1:21 AM
    Tuesday, April 14, 2015 3:08 AM
  • Hi,

    When I say browser mode I mean accessing the report using IE in report manager.

    Another method I have thought of is that, my company tends to deploy two versions of the report to different folders if they are to be regulary emailed.  I could test the ReportURL property to see which folder the report is in - this will be different depending on on if its the browse-able version or not.

    • Proposed as answer by Vicky_Liu Monday, April 20, 2015 1:15 AM
    • Marked as answer by Vicky_Liu Tuesday, April 21, 2015 1:21 AM
    Tuesday, April 14, 2015 9:26 PM