SSRS Dynamic Date Parameters - reporting-services

I'm fairly new to reporting and need help with the following?
I have a report that has two date parameters statically set to default to the last financial year. i.e. the FROM parameter 01/04/2015 and the TO parameter 31/03/2016.
When the actual date next year is 01/04/2017 I need these parameters to change forward by one year, I know I maybe able to do it with a case statement and a getdate + dateadd .

I have a small table which creates a year period based on certain dates which I then join onto the data then I use that to filter.
for instance:
1516
1617
1718
so if #year_period = 1516 then the previous year would simply be #year_period-101 and the future would be #year_period+101

Related

How to define Row Data group in SSRS if we have two parameters to be considered?

Im new to SSRS reporting. Im trying to edit in *.rdl file, where it has row data grouping to view data for a month.
eg: =Fields!EndOfMonth.Value
Here EndofMonth will return September 30th /October 31st etc. So table is grouped by one month data.
I need to edit this for a custom data range.
eg: startdate='2019-09-05', enddate='2019-10-12'
So, report table should display rows between September 5th to October 12th.
I have both startdate enddate parameters defined in the *.rdl file.
But I dont know, how i can switch between both date ranges based on condition. that is , if companyid<>50 pick custom range else standard.
eg:
I defined like this, but here i could point only one parameter(i used enddate only).So report shows rows between October 1st to 12th only.
How can I modify the condition?
=IIF(Parameters!CompanyId.Value<>50,Fields!EndofMonth.Value, Parameters!EndDate.Value)
EDIT
I have 2 datasets defined to switch between companyids.
I modified above condition based on Nicks answer, but i get lookup function can not be used with functions issue.
I tried following both way, but getting same rows again and again
=IIF(Parameters!CompanyId.Value<>50,Fields!EndofMonth.Value,
IIF(Lookup(Fields!TankDateCombo.Value, Fields!TankDateCombo.Value,Fields!Date.Value,"Dataset2")
>= Parameters!StartDate.Value,Fields!EndofMonth.Value,
Parameters!EndDate.Value))
=IIF(Parameters!CompanyId.Value<>67,Fields!EOM.Value,
IIF(Day(Lookup(Fields!TankDateCombo.Value, Fields!TankDateCombo.Value,Fields!Date.Value,"OESNeoData"))
>= Day(Parameters!StartDate.Value), Fields!EOM.Value,
Parameters!EndDate.Value))
MY dataset contains following data;
I fixed this by simply deleting that row group and passing start/end dates for both datasets

SSRS select parameter month and change par. first and last day of this month

i need to create parameter list of months and then (after select) recalculate two others paramateres in date format ([first day] and [last day]) of this month, can you please help me?
You are querying a database server to generate the list of months, although there's no need to do that. I suggest to rather create a list of months in the report and let the report calculate the month's names, so the language depends on the Language setting of the report (which can be the language configured in the user's browser).
For example, to calculate the Label for the Value 1, use an expression like =MonthName(1).
The Parameters FirstDay and LastDay (or just the values whenever you need them) can be calculated using these expressions:
FirstDay: =DateSerial(Today.Year, Parameters!Month.Value, 1)
LastDay: =DateSerial(Today.Year, Parameters!Month.Value, 1).AddMonths(1).AddDays(-1)

Twelve month ago as parameter in SSRS

I have two main parameters in a Report:
First is to be used to set the month (e.g. Dez 2017), from this Parameter the Report shall set its fromParameter itself (e.g. Dez 2016 in this case).
What is the easiest way to solve this issue? Is there a dateadd formula, calculating backwards from a Parameter?
My first Parameter is set by a formula like this(creating the last month):
('[Date].[Fiscal].[Month].&['+Format(DateAdd("d",-39,now()),'MMM yyyy')+ '] ')
Or do I have to calculate the "fromperiod" first in a query? How could this look like?
In the end the reporst should still be flexible, so changing its 12 month period based on would the user is selecting in the end.
Try this expression for the start date parameter default value to set it 1 year before the the parameter end date.
=DateAdd(DateInterval.Year, -1, Parameters!EndDate.Value)
Or you could do the reverse if you wanted to base it off the parameter start date.

SSRS date to and From parameters default to current financial year

I have a Dynamics CRM SSRS report which has two date parameters to filter records when report is executed.
When running the report I would like the parameters to default to the current financial year eg. if today is 01/10/2017 then From should default to 01/04/2016 and To should default to 31/03/2017.
Can this be done and if so what is the best way?
Not sure why people are over complicating this. I understand the common need for date tables, I use them a lot but it's pretty easy to do in an expression.
The From date expression needs to be
=DATESERIAL(Year(Now()) - (IIF(format(now(),"MMdd") > "0331",0,1)) ,4,1)
and the to date expression needs to be
=DATESERIAL(Year(Now()) + (IIF(format(now(),"MMdd") > "0331",1,0)) ,3,31)
All we are doing is creating a date value that is either 1st April current year or 31st March current year then depending on if the current date is on or before the 31st March we adjust the year by 1.
I'M ASSUMING YOUR DATES ARE WRONG IN YOUR EXAMPLE. You said you wanted current financial year but your sample showed last financial year. Anyway, if the code above is incorrect just adjust the Year(Now()) to be (Year(Now())-1) .

Set Default parameter in SSRS from a dataset

How can i set the default parameter in SSRS using a value from Dataset?
I want the default parameter to be the previous month date that is selected from a table tblPeriod(per_id, lastDay)
tblPeriod stores the months in a set of 20 year with last day storing the last day in a month.
e.g
2000, 31-Dec-2016
1999, 30-Nov-2016
I wrote this SP getPeriod which works like this-
select per_id, lastDay , (select per_id from tblPeriod where lastDay < getDate()) as maxDate from tblPeriod
The report populates a drop down with all period values
How to make the default date as previous month end date using the maxDate value returned by the Stored Procedure?
<ReportParameter Name="period">
<DataType>Integer</DataType>
<Prompt>Period</Prompt>
<ValidValues>
<DataSetReference>
<DataSetName>Periods</DataSetName>
<ValueField>per_id</ValueField>
<LabelField>lastDay</LabelField>
</DataSetReference>
</ValidValues>
</ReportParameter>
I would also like to know how to set the top most item in a parameter drop down as the default selected item in the report
Click on default value option then click on function then you can write a function to get the date you are wanting like [#parameterName] will get the entered parameter then use some of the math function to modify it like you need. Your problem is hard to solve without seeing what you are doing in the GUI and you will have to get pretty creative to solve it.
Sorry I can't be of more help. If you add some screen shots I may be able to help more.