Using User!UserID in SSRS to access data in SSAS Cube - reporting-services

I am running SQL 2012 and I have a SSAS multidimensional cube that holds measures for our retail business. I have created an SSRS report that pulls the data from the SSAS cube. I want the user to be able to run the report and only pass the users specific store revenue, customer count, ect, on the SSRS report that they are viewing.
I have created a parameter from the cube. Under the report parameter that was created from the cube I put in under default values, specific values, this expression for the value ="[DimUserTable].[Username].[UserID].&[" + User!UserID + "]", the report will not run. It gives the error;
For more information about this error navigate to the report server on the local server machine, or enable remote errors
Query execution failed for dataset 'Revenue'. (rsErrorExecutingCommand)
Does anyone have any idea how I can accomplish getting only the users store information to show on the report they are viewing?

You only need to pass the user id to the parameter.. your query should take care of the filtering using the parameter. Something like
where [DimUserTable].[Username] = #userid
I would use the following as the default value for the userid parameter
=User!UserID.Substring(User!UserID.LastIndexOf("\")+1)
Of course, this depends on what your cube holds for userid value. If it does NOT include the domain or machine name.. use the above.. else just use =user!userid

Related

An attempt was made to set a data set parameter '#BrandName' that is not defined in this data set?

I'm trying to get data based on the parameter passed in the Power BI report server.
In the SSRS it was working fine
And I have set parameter like below in the shared dataset:
But in the Power BI report server, I'm getting an error like below
Below is query written in my shared dataset
Below is the parameter column for the shared dataset

How to pass parameters to Pentaho Report (.prpt) so that sql query can run dynamically to make report at runtime

I have a static Pentaho Report(.prpt) on my pentaho server.I am trying to find the way to pass paramater to my pentaho report and refresh(update) the report using pentaho scheduler.I am able to run the sql query each time the scheduler runs.
But I want to pass parameter(user data to be used in mysql query) dynamically so that I am able to generate user specific reports for all users using same prpt file on my server.
How can that be achieved? Can anyone explain with an example regarding the dynamic query scripting in Pentaho Report Designer as there is no material which can be found for the same.
I am using Pentaho Report Designer and Server(8.1).
You must first create a parameter on the report (under the Data Tab, choose Parameters and right-click to create a new parameter). Those parameters can be passed from the URL, or set via a selector/dropdown.
Then you can use the parameter by entering it into the query with a syntax such as shown below:
select * from sales where customer = '$(customerParam)'

SSRS: Caching a shared Oracle Dataset with date parameter

I am using SSRS (2008R2) to create a large report against an Oracle
database.
Because of the size of the report I wanted to cache the shared
dataset overnight.
The dataset has a single parameter which should default to today's
date but be changeable in the report (although this would trigger
another cache).
I have struggled with this for 3 days and wanted to document how I got it to work, as well as get feedback on my approach.
1. Oracle Datasource:
I found that passing parameters to the dataset only worked well for me using the native Oracle drivers, not the OLE DB drivers.
2. Shared Dataset:
I was never able to get SSRS to pass a date parameter to Oracle. In my Oracle query I therefore used the conversion TO_DATE(:EffectiveDate,'YYYY-MM-DD"T"HH24:MI:SS') (you'll see why I had to use ISO 8601 format later).
When adding the variable :EffectiveDate to my SQL query a parameter was automatically added to by shared dataset. This initially caused the Oracle error ORA-01008: not all variables bound. This was resolved by deleting the dataset parameter and then clicking "refresh fields" on the dataset query screen to re-create it. The only difference apparently being that now the parameter name has a colon.
I have set the dataset parameter up as shown below in the screenshot:
The parameter is of type "text" and defaults to today at midnight in ISO 8601 format (=Format(Today(),"yyyy-MM-dd\T\0\0:\0\0:\0\0"))
3. Report Dataset:
The Report Dataset uses the Shared Dataset above and also has a dataset parameter. In this case I want the report dataset parameter to take a date from a report parameter but pass a string to the shared dataset parameter as below:
The Dataset Parameter is set to the value =Format(Parameters!EffectiveDate.Value,"yyyy-MM-dd\T\0\0:\0\0:\0\0")
4. Report Parameter:
The Report Parameter is set to "date" type as below with a default of =Today():
5. Shared Dataset Caching:
First I set the Shared Dataset to use cached data (on the report server via your browser):
Then I set up a "Cache Refresh Plan":
The Cache Refresh Plan seems very picky about Parameter format and it was this last step that only seems to work if passing dates as ISO 8601 compliant strings.
6. Notes:
:EffectiveDate is the name of my Oracle string bind variable and EffectiveDate is the name of my Report parameter. Change your code appropriately.
I was only interested in the date (i.e. not the time). If you need time as well you may need to make some changes.
In order to let the end user know how old the data was, I added an extra column ,SYSDATE AS DATA_AGE to my SQL Query. I was then able to reference the age of the data in my report header with First(Fields!Report_Date.Value, "<report_dataset_name")
I am able to create snapshots of the report but all of the prompts are greyed out, even though all the other prompts only effect report filtering.
To have different prompt defaults in my snapshots I used the test IsNothing(User!UserID). I'd love to know if there was a better way.
My example isn't necessarily in the order in which I set things up (i.e. I reference the Report Parameter before showing its setup).

SSRS Code and Automated Reports

I am currently trying to automate reports using SSRS in SQL Server 2008, requiring little to no user input at all.
I have the queries already to acquire the data, but they require datetime parameters which are retrieved from an invoices table in the database.
Is there any way to automate this, without requiring user input? I'd like to have these reports fire off every Monday morning without prompting. We also have an internal web site which is used for administrative work, written in ASP and C#, that I can use in conjunction in need be.
Regards and thanks
You should be able to do this. In each report you can set a query to retrieve parameter values and you can also specify a query for the default values.
So
Add a parameter and have that parameter be passed to your stored proc that gets your data
Set the available and default values for that parameter to a sql query that returns the value you need for the parameter.
You'll need to do this for each parameter. Then as long as all parameters in the report have default values the report will run without prompting for parameters.

How to set the DB as parameter in SSRS?

I'm using ReportBuilder 3.0 for creating report in reporting services 2008. I have many DB with the same tables (different data) and I created a report that can be applied to all these DB. I want to add a parameter to choose the database so the user can choose the DB from which getting the data.
I created a parameter (named "DB") with the name of the DBs as avilable values, but I can't use the parameter in the queries as I was expected:
SELECT *
FROM #DB.[dbo].[TableName]
That query (used in a dataset) doesn't work.
There's a way to set the DB as a parameter?
In TSQL, you would use dynamic sql to do this (EXEC(#CMD)). I doubt report builder will allow you to do this. There are security risks to this.