SSRS output side by side - sql-server

Looking at how to output a certain way.
Right now this is how SSRS outputs my table:
Output1
This is how I would like the table to output:
My expected output

Use Matrix and define the field with ID (777xxx) in the column group

I replicated your Data into my local Report. First step you data is something like below
ID CITY PRIMARYORELEMENTARY
7777888 Houston,TX Elementary
7777889 Houston,TX Elementary
7777890 Mumbai,IN Primary
7777891 Delhi,IN Elementary
Now you could so in your SSRS something like below.
Insert and then matrix
After you have matrix then you see matrix as below. Then in column select ID
Now select Rows and then add row inside group below
Now select Primary Element and City in two rows 1 after another.
Once you follow all the steps, below is how you will get your Report

Related

Create a cross reference table using Golden record and associate other records to the record

I have a table where I have ranked all the rows based on the created date column and have the rank indicated on the table as below
main table
I would like to create a cross-reference table with the golden record as the recurring column and the other two records as associated records as below.
output desired
I would like to know how I can achieve this using SQL.
I have tried creating a seperate table with all ID numbers (Rank = 1) and then joining it with the main table to get the ones with rank 1,2 and 3 associated with it. But it doesnt seem to work as I intend to.
output
I have not tested but something like this should work. You might want to add a name_id field.
select b.id_number,a.id_number
from table a
join table b on a.name=b.name
where b.rank=1

QlikView How to group by attribute in other table

Hello I currently have 2 tables like this:
Parcel which has idParcel,quantityParcel,idProduct
and
Product which has idProduct, nameProduct
When I try to execute Aggr( sum(quantityParcel),[idProduct] ) it works just fine making the sum of quantityParcel by idProduct but when I try to run Aggr( sum(quantityParcel),[nameProduct] ) it just returns the sum of all quantityParcel values without grouping anything, is there any way I can group by nameProduct referencing it from the Product table? The reason I want to do this is because I want to show the actual product name in my dimension instead of just the idProduct number, thanks :)
If you use nameProduct as Dimension why don't just use: sum(quantityParcel)
another option is to use NODISTINCT : Aggr(NODISTINCT sum(quantityParcel),[nameProduct] )

Get a list of columns and widths for a specific record

I want a list of properties about a given table and for a specific record of data from that table - in one result
Something like this:
Column Name , DataLength, SchemaLengthMax
...and for only one record (based on a where filter)
So what Im thinking is something like this:
- Get a list of columns from sys.columns and also the schema-based maxlength value
- populate column names into a temp table that includes (column_name, data_length, schema_size_max)
- now loop over that temp table and for each column name, fetch the data for that column based on a specific record, then update the temp table with the length of this data
- finally, select from the temp table
sound reasonable?
Yup. That way works. Not sure if it's the best, since it involves one iteration per column along with the where condition on the source table.
Consider this, instead :
Get the candidate records into a temporary table after applying the where condition. Make sure to get a primary key. If there is no primary key, get a rowid. (assuming SQL Server 2005 or above).
Create a temporary table (Say, #RecValueLens) that has three columns : Primary_key_Value, MyColumnName, MyValueLen
Loop through the list of column names (after taking only the column names into another temporary table) and build sql statement shown in Step 4.
Insert Into #RecValueLens (Primary_Key_Value, MyColumnName, MyValueLen)
Select Max(Primary_Key_Goes_Here), Max('Column_Name_Goes_Here') as ColumnName, Len(Max(Column_Name)) as ValueMyLen From Source_Table_Goes_Here
Group By Primary_Key_Goes_Here
So, if there are 10 columns, you will have 10 insert statements. You could either insert them into a temporary table and run it as a loop. If the number of columns is few, you could concatenate all statements into a single batch.
Run the SQL Statement(s) from above. So, you have Record-wise, column-wise, Value lengths. What is left is to get the column definition.
Get the column definition from sys.columns into a temporary table and join with the #RecValueLens to get the output.
Do you want me to write it for you ?

How to show data in column in SSRS

I'm using SSRS for my reporting, my reporting solution is in Visual Studio 2008 Business Intelligence Development Studio.
I have a report in which the data should be displayed in this format.
I have added a Column Group in my table which is having the values of Customer Name and details, the data is coming fine in the vertical format i.e column after column.
My Issue :
There should be only three columns in each row, after three records the next row should begin and again not more than three records should be displayed as shown in the image above.
My attempts :
I tried to add a row group and in that gave the expression
= Ceiling(Fields!Row_Count.Value/3)
here Row_Count is a field which is coming from my query which holds the serial number of the records.
My SQl Query
SELECT Row_Number() over(order by table_ID) AS Row_Count, Field_1,Field_2 from MyTable
In my Column group i have Customer Name and in my Row Group i have other details of the customer. The data is getting populated column wise but the issue is its not breaking the current row after three records.
Below is my table of report.
You were on the right track. Say you have data like this:
I have created a tablix like this:
The Row Group expression is:
=Ceiling(Fields!Row_Count.Value / 3)
This works together with the Column Group expression to split over three columns:
=(Fields!Row_Count.Value - 1) Mod 3
The other thing to note compared to your tablix is that CustomerName is not in a table header row, but rather there are two row header rows, one for CustomerName and one for Details.
This is looking OK to me, obviously you can format to taste:

Insert distinct data into a new table using select and calculate sums at the same time

Using MS SQL I'm trying the following:
I have one table with game data. In this table a player name can occur many times.
I now want to create a summary table, where every player has a single row.
Using the following statement, I can populate the summary tables "playername" column.
INSERT INTO PLAYER_Summary (Playername)
SELECT DISTINCT [Playername]
FROM ppPLAYER
The summary table also has columns for sums of the players results.
How can i populate my summary table so that each name and the correlating sums are in it once.
I need something like:
INSERT INTO PLAYER_Summary
(Playername, WinWhat )
SELECT DISTINCT [Playername] FROM ppPLAYER , SUM(WinWhat) FROM ppPLAYER
How can I make this work and parse the unique playername with his sum?
Thanks
INSERT INTO PLAYER_Summary
(Playername, WinWhat )
SELECT Playername, SUM(WinWhat)
FROM ppPLAYER
group by Playername

Resources