My SQL query needs to return data grouped by requirement. To do so, it needs to group by more than one column.
Example SQL:
SELECT
[MainMenu],
[Submenu1],
[Submenu2],
[Submenu3],
[Submenu4],
[Submenu5],
[Submenu6],
[Submenu7],
Sum([MainMenuReturn]) AS "Total Returns",
[ExitReason]
FROM [dbo].[Custom_IVRMenuUsage]
GROUP BY MainMenu,Submenu1,Submenu2,Submenu3,Submenu4,Submenu5,Submenu6,Submenu7,ExitReason
This will return each combination of the groupings and keep the column separated data. I cannot do this in Crystal. If I concatenate the columns into one field to group by, I lose the ability to keep the data separated into their columns for formatting.
How can I accomplish this in Crystal without writing a separate stored procedure?
Related
I have a database of users purchase/sell of stocks and need to retrieve the data by summing all the shares for that specific user.
Ex: If I choose user_id = 7, it should return two rows, one with TESLA and one with Apple with the sums of the shares.
Database:
SQL queries I've tried include:
SELECT name,symbol,name,price,total, SUM(shares)
FROM symbol
WHERE user_id=7
GROUP BY name,symbol,name,price,total
Returns: but it should just be two rows
Your issue is your grouping.
Consider the uniqueness of what you are grouping by and that is how many rows you will get returned.
With your where clause and grouping by name,symbol,name,price,total there are three unique rows.
Remove the price and total columns from the grouping and you will get your desired two rows, or include them in your query as sum'd columns.
eg.
SELECT name,symbol,name,SUM(shares)
FROM symbol
WHERE user_id=7
GROUP BY name,symbol,name
I have two datasets (one is a stored procedure written by a vendor that cannot change). Stored procedure is the main dataset. I am using a second data set to bring back filtered results. The second dataset contains already filtered records.
Trying to use the Tablix filter:
=Lookup (Fields!UserGUID.Value,Fields!UserGUID.Value,Fields!MembershipPolicyGUID.Value, "Dataset2")
I have a group that needs to display only the records in Dataset2.
Dataset2 is written using a where statement only displaying
MembershipPolicyGUID not in'00000000-0000-0000-0000-000000000000' and '29976BA0-E2D7-494E-A1CE-20E609C76929' (these numbers are stored as text)
I need help in how to filter the records.
I have tried the <> in the Tablix filter using the above expression, but it does not work or rather it does not return any records from Dataset2 except those from Dataset1.
Figured it out. The filter should be:
expression =Lookup (Fields!UserGUID.Value,Fields!UserGUID.Value,Fields!MembershipPolicyGUID.Value, "Dataset2")
then operator >
then value 0
I am new to using Tableau.I want to count the number of times each genre appears in the data set.
In the data set(image attached), I have several genres for one show. I want to count the number of each genre in the data set and display it in Tableau
If you have access to database, then take the dump of data in a excel.
Split the data by , and then create a individual column for every word in the genre column.
Now take the excel as source to tableau, In tableau pivot the splitted columns of Genre.
Go to sheet in tableau, Place the pivot field values in rows and count of pivot field values as measures.
You should be able to see the desired result.
This can be done by an alternative method if you know the distinct list of all genre.
what you need to do is to create a separate calculative field for each Genre using
if contains(Genre,'action') then 1 else 0 end
and then use the Sum of these field as the count of Series per genre.
I know this is a hideous task but, it can be done if you do not have any other option.
I am working on ssrs which uses a table. I need to get values into the table from two dataset which comes from single datasource.
you can define the over all table data set to one of the data sets which is used maximum to pull in the values to the table. For columns which has to use the second data set, in the Expression properties window, select the Dataset from the Catogery list and then you can select the dataset name and the valuew associated with it.
If you're using SSRS 2008 R2 you can use the Lookup() function in an expression in your table to pull in values from other datasets based on a lookup key or other joinable field. Lookupset() would allow you to retrieve multiple records at once if you need to deal with a 1:many relationship.
See here for more:
http://technet.microsoft.com/en-us/library/ee210531.aspx
http://technet.microsoft.com/en-us/library/ee240819.aspx
This will not work if you're on plain old 2008.
I am attempting to join two datasets in to one tablix for a report. The second dataset requires a personID from the first dataset as its parameter.
If i preview this report only the first dataset is shown. but for my final result what i would like to happen is for each row of a student there is a rowgrouping (?) of that one students modules with their month to month attendance. Can this be done in report builder?
The best practice here is to do the join within one dataset (i.e. joining in SQL)
But in cases that you need data from two separate cubes(SSAS) the only way is the following:
Select the main dataset for the Tablix
Use the lookup function to lookup values from the second dataset like this:
=Lookup(Fields!ProductID.Value, Fields!ID.Value, Fields!Name.Value, "Product")
Note: The granularity of the second dataset must match the first one.
We had a similar issue and that can be resolved this way.
First of All, ensure the first data set's query and second data set's query are working fine by executing separately on the Database client tool such as Datastudio.
Build two data sets on SSRS tool with the respective queries and make sure both the data sets have same key column (personID).
On the SSRS report design, create a table from tool box and add the required columns from the first data set along with the matching key column(personID). Add a new column and use look up function to get the required column from the other data set against the same key column (personID).