I have been trying for some time to get a Parameter to work within an MDX Query which is automatically generated by SSRS Query Designer.
I have tries the following:
FROM ( SELECT ( {[Dim Date].[Fiscal Year].&[+"#Current_FYear"+]}) ON COLUMNS
FROM ( SELECT ( { [Dim Date].[Fiscal Year].[+"#Current_FYear"+} ) ON COLUMNS
FROM ( SELECT ( {StrToMember(#Current_FYear,CONSTRAINED).lag(23):StrToMember(#Current_FYear, CONSTRAINED)}) ON COLUMNS
FROM ( SELECT ( {[Dim Date].[Fiscal Year].[+"Parameters!Current_FYear.Value"+]}) ON COLUMNS
And none of the above give me the result i am looking for: To have the Dataset filter by the value in the Parameter.
Any help on this would b emuch appreciated!
Thanks,
First of all, I would suggest using the Parameter checkbox in the Query Designer and let SSRS build the MDX for you. Here's a screenshot in case you missed it.
Another reason to let the report create the parameter for you is that it will automatically create another hidden Dataset to populate the available values of the parameter.
If you do want to edit the MDX manually, the syntax could look like this:
SELECT NON EMPTY { [Measures].[Measure] } ON COLUMNS FROM (
SELECT ( STRTOSET(#Parameter, CONSTRAINED) ) ON COLUMNS FROM [Model])
The STRTOSET function converts the parameter value into MDX syntax. It can also handle multi-value parameters.
The parameter you reference here would also need to be defined in the Parameters tab of the Dataset Properties. This is where you link the parameter value from the report to the query.
Related
Users want to have an option to control which columns are present in the final report.
One option is to get a list of fields requested. Is it possible in SQL Server to write a query like this? But I need to select a list of values, not just a single variable.
My plan is to get a parameter's list from a query like this:
SELECT
CONCAT ('Table2.', name) AS ColumnName
FROM
sys.columns
WHERE
object_id = OBJECT_ID('Table1')
The user would select columns they need this time, and then I want to use parameter list somehow like that:
SELECT #ColumnName FROM Table2
Of course it's not working this way...
Is there an option to get result that I want?
Check 'allow multiple values' for your parameter
In hide/show expression of the visibility of the column, put:
=IIF(instr(join(Parameters!ParamName.label,","),"NameColumn_to_filter")>0,false,true)
I have a query to result in the below data from DB
But actually, I want to get the data as
Is there any way we can do this the SSRS?
How can I do this? really stuck
You can do this easily in SSRS without changing your dataset.
Add a Matrix control to your report
Drag the Assignee field to the Rows placeholder
Drag the Priority_n field to the Columns placeholder
Drag the Count_C field to the Data placeholder
that's it. If this does not help, let me know and I will update with sample images.
Please recheck the column names;
SELECT * FROM (
SELECT
[Assignee],
[Priority_n],
[Count_C]
FROM dataset
) Results
PIVOT (
SUM([Count_C])
FOR [Priority_n]
IN (
[High],
[Medium],
[Low]
)
) AS PivotTable
I'm using Report Builder and want to add more than one value against a Label (Available Values > Specify Values):
Example:
Label = "labelone" Value = Value1, Value2...
When I run the report, I get a message saying Parameter1 is missing.
I have tried following against value: Value1, Value2 and 'Value1', 'Value2'
My query has following in the where clause: WHERE (FIELD in (#Parameter1))
Basically, I want to specify multiple values against one label under the parameter.
Thank you
You cannot do this directly as what will get passed to the query would be
WHERE Field IN ('Value1, Value2')
or
WHERE Field IN ('''Value1'', ''Value2''')
The way to do this would be split the label using a table valued function, you could use string_split if you have a fairly recent version of SQL Server (I think this was introduced in SQL2016). If you have an older version there are loads of sample of string splitting functions around tha you could use.
Once you have you function you can join to the results of that, the query would be something like
DECLARE #pValues TABLE (myValues varchar(10))
INSERT INTO #pValues
SELECT * FROM string_split(#myReportParameter, ',')
SELECT *
FROM myTable a
JOIN #pValues p on a.Field = p.myValues
I have a dataset which brings in distinct values of a column 'A' of table 'B' and these form the select values for a parameter 'Param_A'. In addition to this I have a main dataset which brings in data from table 'B' and contains the column 'A' as 'Field_A'.I do not want to alter the main dataset and hence I am using a tablix filter to filter out the result set of the main dataset. The tablix filter is supposed to be performing the below functionality :
Expression:
Fields!Field_A.value in (Parameter!Param_A.value) or Fields!Field_A.value is NUll
Boolean Operator :
"="
Value:
True
But I am unable to use the operator 'in'. It gives me an error.Could you please help me out with this?
I used the 'inStr' Operator which eliminated the possibility of using 'in' operator:
iif(InStr(Join(Parameters!Project.Value,","),Fields!project_name.value)>0,
true,false)
This helped me!
I have a mdx report on a cube. As available values for division number report parameter I have an autogenerated dataset (dataset1, with all divisions in company) which query looks like this:
WITH MEMBER [Measures].[ParameterCaption] AS
[Dim Division].[Hierarchy].CURRENTMEMBER.MEMBER_CAPTION
MEMBER [Measures].[ParameterValue] AS
[Dim Division].[Hierarchy].CURRENTMEMBER.UNIQUENAME
MEMBER [Measures].[ParameterLevel] AS
[Dim Division].[Hierarchy].CURRENTMEMBER.LEVEL.ORDINAL
SELECT {[Measures].[ParameterCaption], [Measures].[ParameterValue], [Measures].[ParameterLevel]}
ON COLUMNS ,
[Dim Division].[Hierarchy].ALLMEMBERS
ON ROWS
FROM ( SELECT ( STRTOMEMBER(#FromDimDateHierarchy, CONSTRAINED) : STRTOMEMBER(#ToDimDateHierarchy, CONSTRAINED) )
ON COLUMNS
FROM [ArveCubeBiceps]
)
I have another dataset (dataset2), which consists of only those division numbers, which logged in user is supposed to be able to view (data supplied by a procedure). I need to filter dataset1 available values by the values of dataset2.
-I can't just use the dataset2 as available values for division number, since report query is MDX, and expects tuples, which dataset2 doesn't provide. When I try to concatenate dataset2 values into tuples, I get an error that I can`t use "&" for Object() type.
-When I create a hidden parameter on report, which available and default values are those from dataset2, and then apply a filter expression to dataset1 query, which says "DivisionID in #hidden_parameter" - I get no available values for the Division parameter ( I checked the tables, all data is there )
What do I have to do to get this filter expression working... please help anyone :)
#mmarie
second dataset is created by stored procedure:
USE [Biceps]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[ArveDivisionsByUserID]
#ldapuid nvarchar(30)
AS
BEGIN
declare #hier as hierarchyid
declare #managerID as int
select #managerID = em.employeeID from Dim_Employee2 em where em.ldapuid = #ldapuid
select #hier = dv.hier from Dim_Division dv where dv.managerID = #managerID and hier is not null order by hier desc
select divisionID from Dim_Division dv where hier.IsDescendantOf(#hier)=1 order by hier
END
#FrankPI - offtopic
don't know why, but I used ctrl+k for code, but it`s still regular text :(
If you can change the second query, then this could return the list of allowed members as a set definition string instead of a list of members, using e. g. the SetToStr function. This could then be used in the first query as a parameter replacing the text [Dim Division].[Hierarchy].ALLMEMBERS for the rows by StrToSet(#AllowedDivisionSet, CONSTRAINED).
If the result sets are not huge, the easy way is to do this is with a filter on the Dataset and NOT in MDX:
Add a Boolean filter in which the Expression is =True and the Value is something like this:
=iif(instr(join(Parameters!DataSet2Parameter.Value,","),
Fields!ToDimDateHierarchy.Value)=0,True, False)