SSRS - Creating distinct parameter values from SSAS OLAP cube - reporting-services

I have a list of names and email addresses (formatting below) and need to pull back only the names portion, and I need them to be in a distinct list to populate in a parameter.
Current List
Jane Doe (jdoe#example.com)
Jane Doe (jsmith#another.com)
Jane Doe (frosen#whoknows.com)
John Smith (kmittens#santa.com)
John Smith (wlamberson#rogerthat.com)
Desired List
Jane Doe
John Smith
Since the data source is an SSAS OLAP cube I cannot write a "select distinct" query within my dataset. Instead I am limited to using the Query Designer via a shared data source connected to the cube.
Has anyone else ever run into anything like this and found a solution? I've been looking all over and can't find anything.
Any help would be appreciated!
Thanks

Try this:
With MEMBER [Measures].[Name]
AS
LEFT([Customer].[Customer Name].CurrentMember.Name,
InStr([Customer].[Customer Name].CurrentMember.Name,'(')-2
)
select [Measures].[Name] on columns,
DISTINCT([Customer].[Customer Name].[Customer Name]) on rows
from [Mycube]
It will give you a list of distinct customer names as long as customer name is composed of:
name (email)

Related

How to Count Duplicated Names in a Varchar/Text Column in MySQL/Any SQL

So, this is the situation: I have a CSV file who looks like this:
show_id title cast
1 Batman Robert Pattinson, Collin Farrel, Zoë Kravitz
2 Twilight Robert Pattinson, Kristen Stewart
3 Ava Jessica Chastain, Collin Farrel
What I need to do is open this CSV in a Python function, do some stuff to fix white spaces and that.
Then I need to upload that in a SQL database, (whatever I want, but I choose MySQL), no problem with that.
PROBLEM
My main issue is that then I need (because mi challenge said that) to create a Query to count how many times an actor appears in all the movies in the list. So, in this case the query should display something like this:
Actor Amount_of_movies
Robert Pattinson 2
Collin Farrel 2
Zoë Kravitz 1
Kristen Stewart 1
Jessica Chastain 1
As you can see I don't have a name to search with LIKE or CONTAINS. So, how can I do that? Because, in the CSV, the list of actors per movie has, well, more than 1 actor, and I save them in a varchar or text type in the database, so each row has more than one actor.
Or should I create another table with actors and foreing keys to movies? Or is something than I can't do in MySQL but in other SQL is possible?
If you look for something performance efficient you should rather split the data (create 3 tables in total - movies, actors, casts) and connect actors with movies using the casts, then write simple sql with some joins like:
Select actors.name as Actor, count(movies.title) as Amount_of_movies from actors,
inner join cast on cast.actor_id = actors.actor_id
inner join movies on movies.movie_id = cast.movie_id;
You are able to do it another way using https://sebhastian.com/mysql-split-string/ or using psql / plsql and stored procedure. I would just split the data if it's possible.
Cheers.

How do I aggregate more than one result into a SSRS list report

I am creating a SSRS list report based on this SQL:
select name, job_id, job_title from HR
name job_id job_title
--------- --------- ---------
Mike Jones 123 Manager
Mike Jones 775 Analyst
Patty Bea 562 Director
Patty Bea 964 Deputy CFO
After creating the design and previewing the report, I get 4 pages based on my SQL results.
When a name has more than one jod_id and job title, I would like to list both on one preview page of the SSRS report.
Your preview looks like your desired result - 'I would like to list both on one preview page ' - rather than the 4 page current result.
If you haven't done it - you'll want to only GROUP on the name and use a LOOKUPSET to get all the values associated (and use a JOIN to combine them into a single string):
=Join(LookupSet(Fields!name.Value, Fields!name.Value, Fields!job_id.Value, "DataSet1"), ", ")
The LookupSet looks up all the results that match the name field (argument 1) to the name field of the dataset (argument 2) and gets the job_id field (argument 3) from DataSet1 (argument 4).
For the job_title field, do the same but change the job_id field to job_title.

ms access create report with two tables

I am needing to create a report between two tables. One table has ID, FirstName, LastName. The seconded table has NoteID, ID and Notes. There is a one to many relationship. Each person can have many notes. What I would like to do is fill a listbox or textbox with the notes that belong to that person.
On that note, how can I create a report that will display somewhat as the following:
First Name: Jeff Last Name: Smith
Notes:
This is note 1 for Jeff Smith
This is note 2 for Jeff Smith
This is note 3 for Jeff Smith
This is note 4 for Jeff Smith
First Name: Kim Last Name: Yung
Notes:
This is note 1 for Kim Yung
This is note 2 for Kim Yung
Thank you for any thing on this to lead me in the right direction.
Okay - so I made a query to use as the Record Source for the Report.
SELECT People.ID,
People.FirstName,
People.LastName,
Notes.NOTES
FROM People INNER JOIN Notes
ON People.ID = Notes.ID;
I clicked report design, set this query as the Record Source for the report.
I added a GROUPING on ID (this is to separate each person's Notes).
This created an ID HEADER, which is where you put FirstName, LastName, and your Notes label.
In the Detail section, you put the NOTES field from your query.
Output
If you have any other questions, let me know.
What you need is a Subreport. A Report that will have another report in it. This works in a similar way to a Main Form and Sub Form. More information is available on the MS Office website : https://support.office.com/en-ca/article/Create-and-use-subreports-816f987a-4615-4058-8f20-ce817093bb33

How do I output the mutual results appearing in two queries?

I have made 2 simple queries which output the forename and surname of people based upon the value of a column "role" in a junction table they are associated with.
Lets say that the output is:
Kevin Baker
Julie Willis
Gregory Hilliard
Joe Swanson
Patrick Day
Bethany Row
for one of the query outputs and:
Kevin Baker
Michael Winter
Ellie Patterson
for the other.
I want to be able to make a query which outputs the values that appear in both of these tables i.e. I want it to output Kevin Baker in this case.
Is there a simple way to do this based upon the two queries I have already made?
I have managed to do it myself. I am not sure if it is the best method but it was simple and works.
I kept the first query the same and added
AND IN()
to the end of the WHERE statement.
I then pasted the second query into the IN statement and altered it to only SELECT the id of the related attributes in the outer query.
If you need an intersect just JOIN these queries:
Select Q1.Name FROM (QUERY1) Q1
JOIN
(QUERY2) Q2 On Query1.Name=Q2.Name

Counting the number of pattern occurrences in a certain column with MySQL

I want to search the column Name of a certain table to see how many rows have a Name value that matches a certain pattern. For example, if the pattern I am looking for is %Peter% and in this table there are 5 rows with the Name values:
Peter
Peter Smith
George Peter
Peter Peter
Carl
I want to obtain the value 4. I tried to use COUNT, but don't know how to combine it for example with LIKE. How do I go about to do this?
Not sure why didn't LIKE work for you, but this SHOULD do the trick:
SELECT COUNT(*) FROM table
WHERE name LIKE '%Peter%'