I have a report with a single parameter Date/Time.
The available values are from query
select cast(getdate() as date) c1 union all
select cast((getdate() - 1) as date)
But both VS preview and SSRS 2017 show that parameter values in dropdown/combobox and no date picker is presented. I need a date picker.
Any idea what's wrong ?
I tried converting it to various date types but nothing works. It doesn't work in IE, Chrome, nothing.
This is the rdl code:
<DataSets>
<DataSet Name="ds">
<Query>
<DataSourceName>SSDB</DataSourceName>
<CommandText>
select cast(getdate() as date) c1 union all
select cast((getdate() - 1) as date)
</CommandText>
</Query>
<Fields>
<Field Name="c1">
<DataField>c1</DataField>
<rd:TypeName>System.DateTime</rd:TypeName>
</Field>
</Fields>
</DataSet>
</DataSets>
<ReportParameters>
<ReportParameter Name="Date">
<DataType>DateTime</DataType>
<Prompt>Date</Prompt>
<ValidValues>
<DataSetReference>
<DataSetName>ds</DataSetName>
<ValueField>c1</ValueField>
<LabelField>c1</LabelField>
</DataSetReference>
</ValidValues>
</ReportParameter>
</ReportParameters>
<Language>en-US</Language>
From my testing and what I've done personally in SSRS, the issue is with you specifying a specific set for available dates. The answer on this link describes what happens well.
Using a dataset to assign values to a filter, you must agree, is a typical practice of single-select and multi-select filters. By specifying values, you are telling SSRS some date values are legal, while others are illegal. The only way it can forbid illegal values be entered by the user is by taking away the anything-your-heart-desires-to-choose date picker.
Basically, the point is that you won't have an option for a date picker if you add anything to the available values. You can set a default value with no problem, but with no available values provided, you will see the date picker.
Related
I am working on Microsoft Dynamics Reporting service. My requirement is to show records which is dated 3 years or earlier from a given date. The parameter I have is a date selection field. What I am trying to achieve is get records based on my condition from the date I have selected on the parameter.
To filter data based on the current date, I can use:
<condition attribute="modifiedon" operator="olderthan-x-months" value="36" />
But, to get the data filtered based on the parameter value is what I can't figure out.
Can someone help me with this?
You should use between operator, but in fetchxml you can achieve it this way.
<filter type="and">
<condition attribute="modifiedon" operator="on-or-after" value="2016-10-04" />
<condition attribute="modifiedon" operator="on-or-before" value="2019-10-03" />
</filter>
Also expression can help you to calculate and pass parameters.
We can add a dynamic date for the report. We can add another date which will have a custom code to have a date 3 years prior to the input date or current date. This date can be referenced to the FetchXML query to filter the records.
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.
I am generating SSRS reports using SharePoint list and using below Caml query in my dataset.
<RSSharePointList xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<ListName>Test_FAMM</ListName>
<ViewFields>
<FieldRef Name="Region" />
</ViewFields>
</RSSharePointList>
However, I want to get only distinct values of the parameter.
Any modification?
Unfortunately, CAML doesn't allow use of DISTINCT. There are a couple of workarounds that you may be able to use.
See:
https://sharepoint.stackexchange.com/questions/77988/caml-query-on-sharepoint-list-without-duplicates
Or:
What is the best way to retrieve distinct / unique values using SPQuery?
I have a report that uses date params (so have to be datetime in SSRS, which sucks to start with). When the user enters a date such as "5/1" it creates a DateTimeOffset data type and I can't find anyway to cast it to anything else, format it, or concatenate in a text box. I tried casting to a date to a string, etc. All I get is:
Conversion from type 'DateTimeOffset' to type 'String' is not valid. ('String' is replaced by anything I try to cast it to)
Surely there must be a way to have a text box show "From 5/1/2013 to 5/31/2013" when the user types "5/1" and "5/31" in the date field? Does Microsoft really think computer-literate people want to pick up the mouse to use their date picker instead of using tab?
Try the following expression:
="From " & Format(Parameters!Param1.Value.DateTime, "M/d/yyyy") & " to ..... etc"
To test this expression I've created a fresh report, added a DateTime parameter, and entered "5/1" in the textbox, hit enter. The report comes up with the following textbox:
From 1/5/2013 to ..... etc
For my locale, this is correct, because when entering DateTime values days are assumed to come before months. When the report is viewed the textbox will also update and show:
5-1-2013 0:00:00 +01:00
From this you should be able to extrapolate and use it for a second parameter as well, extending the expression to show the exact string you need in your report.
The Parameters!Param1.Value.DateTime helped when the user omits the year, but it broke down when the user decides to include the year. I couldn't get it to work under both conditions.
Try this.
Include the date parameter value as a field in your resultset. Your SQL might look like:
SELECT field1, field2, Convert(date, #FromDate) [FromDate_param] FROM table
Then you can create an expression in SSRS like:
="From " & Format(First(Fields!FromDate_param.Value), "M/d/yy")
I have a requirement to include a null value in multi valued parameter. I'm using fetchXML code in my dataset. Please help me with it.
In my report I have 2 datasets in which first one is main dataset having parameter #P1.
For #P1 I have assigned Dataset2 as "Availible values" and "Default values".
Now, when I run the report I should get a dropdown with list of all values in dataset2.
So, here in that dropdown I was asked to add a null value also. Is it possible?
Note:Parameter will accept multiple values from user.
You can add a CRM filter parameter to your report, by adding a blank-value report parameter to your SSRS report.
The XML for the parameter would be like the following, considering you are working for example with the Account entity:
<ReportParameter Name="FilteredAccount">
<DataType>String</DataType>
<Nullable>true</Nullable>
<DefaultValue>
<Values>
<Value></Value>
</Values>
</DefaultValue>
<AllowBlank>true</AllowBlank>
<Prompt>FilteredAccount</Prompt>
<Hidden>true</Hidden>
</ReportParameter>
After you add this parameter, you will upload the report to CRM, and CRM will automatically create the parameter for you as SQL query (Value) and will load CRM filters. Any specific required filters could be saved to the report in CRM.
And note that this report parameter should be passed from SSRS to the stored procedure, which fetches the report filtered results.
You could also find details about CRM 2011 report pre-filtering parameter in this blog
post
http://carlwillis.blogspot.com/2012/01/pre-filtering-in-crm-2011-ssrs-reports.html
Let's say you want to add a null option for selection to a list of codes from a query. All you need to do is add that to your result set by unioning it:
SELECT NULL AS Id, '<Null option>' AS Description
UNION ALL
SELECT Id, Description
FROM CodeTable
ORDER BY 1