Visually representing a denormalized dataset in SQL reporting services - sql

I'm trying to take a denormalized data set and turn it into a report containing a horizontal table layout of data grouped and subgrouped. I realize there are probably better ways to contain the data and better ways to visualize this data, but this is what I have to work with.
Here is the scenario... I have the following CustomerOrderDataTable:
With the following data:
And I'm trying to get it to look like:
The one final requirement on this is to allow for jagged data groups, butting up against each other vertically like:

For your first table you can do something like this.
Set a matrix with one column group, grouped on CustomerId:
There are only two textboxes - one has CustomerName. Insert a table into the other textbox:
This embedded table is grouped on OrderId. OrderDate is displayed in the group header and OrderItemName in the detail row. Since this is embedded in the column group, the table will be repeated for each customer and only display rows in that Scope.
Final result looks like this based on your data:
Not 100% sure about the stacked grouping, but hopefully this will be of some use.

Related

One column per report page

I have a 4x4 table in SQL with 20 rows. I want to split this data into four pages. Page 1 has the first 10 rows of the first column, Page 2 has the first 10 rows of the second column, etc.
After every four pages, this patern repeats showing the next 10 rows from the first column, etc. How can I arrange this?
I could arrange the data of the 4x4 table into another temporary table with just one column in its schema. Then I could read a single column of this table into my report. But can I instead do this directly without an intermediary table?
The intermediary table sounds like the best solution to me. I'd just write a custom SQL command in Crystal's Database Expert to arrange the data as you see fit.
You could in theory pull this off with repeating subreports in some manner of repeating header, but it would be much less work to have SQL properly format the incoming data for you.

How to Combine Multiple Tableau Columns

Let's say I have two columns in the data called
Functionality_First_Question and Functionality_Second_Question
Both columns have similar values
"approve", "functionality unclear", "functionality broken", NULL, etc.
Each row corresponds with a single, distinct review ID.
I thought about using Tableau combined fields to aggregate the data but will it end up turning into "functionality unclear, functionality broken".
I instead want just a distinct count of how many review IDs are associated with each answer to each question.
Let me know if this is unclear!
Depending on your data source, you can pivot the data in the data source tab:
highlight your First_Question, Second_Question, Nth_Question columns
right click
Pivot data
Now you have several records for each item (one record for each question) and you will be able to group all items by answer.
If this is not possible with your data source, one crude workaround would be:
Create a parameter Answer_param with the different possible answers
Create a calculated field that has a formula like
CONTAINS([First_Question], Answer_param) OR CONTAINS([Second_Question], Answer_param) OR ..
This will create a field that is True, if one of the answers contains the selected answer from your parameter.

Qlikview: how to create summary table to filter multiple associated tables

I have 4-5 tables of single and many rows per ID. I want to generate a summary table listing each ID along with various counts and max/mins, but I want to be able to filter on calculations. Example: "ID" is the identifier and there are two tables, TestA and TestB.
One desired selection criteria: Show only those IDs where at least one TestA score >5 and there is at least one TestB score.
In a straight table, this is simple to do with expressions, but the resulting table cannot be selected on the calculated true/false value.
I think I need to create a new table in the load script containing the ID, and then various conditions labeled as I wish. Then, these fields could be dimensions. This seems similar in concept to a master calendar. Am I on the right track?
If it helps to understand my example, this a medical application; the tables are lab results and other interventions that each require complex queries pulling data from various sources that are very "hard-coded" to produce a small data set from millions of rows of highly normalized source data. The desired dimensions would be combinations of the labs so as to allow identification of patients who meet certain criteria--then, once filtered, there would be many more graphs and charts to identify what tests and procedures were followed for that group of patients.
My current data model just loads many tables which then associate on ID. I had attempted to load all data into one big table using concatenates and calculations, but this did not seem to accomplish what I needed and was difficult to manage.
IIUC, I think what you want to do can be accomplished with a combination of sliders/input boxes, variables and calculated dimensions in your table. The process is definitely burdensome, but it should allow you filter the way you want.
Add a field to your table load statement in your script like rnum as RowNo().
Create a variable for your filter(s). Ex. vFilterTestAScore.
Add a slider or input box to your dashboard and point it to that variable.
a. For slider, the option is in the General tab -> Data header -> select the Variable radio button.
b. For input box, add the correct var from the list to the list of Displayed Variables.
Set sliders/input boxes to the criteria you want: vFilterTestAScore = 5 and vFilterTestBScore = 1
Create a straight table with ID as the dimension and expressions for TestAScore and TestBScore. The expression formulas would be sum(TestAScore) and sum(TestBScore) respectively (this won't make sense until the next step).
Now add a calculated dimension to you table. The idea here is that rather than just having the ID dimension, you will create a calculated dimension that only displays the ID of the records that meet the criteria you select in the slider or enter in the input box. The formula should be something like:
if(aggr(sum(TestA), rnum) >= vFilterTestAScore, ID, null()) or for multiple filters: if((aggr(sum(TestA), rnum) >= vFilterTestAScore) and (aggr(sum(TestB), rnum) >= vFilterTestBScore), ID, null()).
On your new calculated dimension, check the 'Suppress When Value is Null' box so only results that meet your criteria are displayed in your table.
To summarize, you are using the variables to store your selection criteria which you are entering via input box or slider. Then you are conditionally displaying only the ID's in your table that match those criteria via a calculated dimension and 'Suppress When Null' option.
I can send you a .qvw if you aren't using the free personal edition and are able to open other qvw's.

PowerPivot - How to filter columns yet retain grand total

in the table below, I would like to graph a subset of the columns, specifically the ones highlighted in green. however, I would like to compute the percentage based upon the grand total of the whole set. filtering columns rescopes the data set and hence the denominator.
I would like to show and graph columns "4" and "Excellent value (5)" while retaining the current "Grand Total." for the ct row, for example, the value would be 8/14 for column "4", and likewise for other cells.
as a candidate solution, I created a secondary table which references the table shown below. is this the cleanest way to accomplish the goal? it seems a bit kludgey and rather time consuming.
ultimately this graph will be rendered in sharepoint so it needs the dynamic interaction with the ssas data. I am assuming that this will be the case since my derived table is using the GetPivotData function which the parent table uses.
You need an ALL() to open out the filter context which in turn means that it doesn't matter which columns are selected.
Assuming you have a table called 'table' and a column called 'response_id' you could use something like:
= SUM(COUNTROWS(table)) /
CALCULATE(COUNTROWS(table), ALL('table'[response_id]))
If your real life problem is more complex then you might need to adjust the ALL() to include other columns or look at ALLEXCEPT() to do the opposite.

how to display parent record and children from multiple tables

I have three tables, 1 parent with 2 child table 1-to-many relationships.
table 1: People
table 2: Phone numbers (any number of records)
table 3: email adresses (any number of records)
I would like a report looking like this:
Person1:
First_Name-------Last_Name
phone1:------12345----Home
phone2:------54321----work
mail1:-------first#mail.com----work
mail2:-------first#mail.com----work
mail3:-------first#mail.com----work
Person2:
-------First_Name-------Last_Name
phone1:------12345----Home
phone2:------54321----work
mail1:-------first#mail.com----work
mail2:-------first#mail.com----work
mail3:-------first#mail.com----work
I would very much like to do this using reporting services.
Edit: I know how to link all tables with left joins, I don't have a concept as how to get this done.
OK, here's a sort of summary of how you need to approach it. I can't give you a step-by-step because it would be impossibly long, but this should get you started. (Also note that I'm doing this from memory):
You will need three datasets, one each for people, phone numbers, and email addresses. I am going to assume that the phone numbers and email addresses have some kind of ID field in common, some way to tie people to phones and to email addresses. You will need that field in your datasets.
You don't need to do any joins in your SQL: the linking between the three datasets will be done within the report.
Put a Matrix on your report. Have it draw from the People dataset. Put the first and last name in the detail row of the Matrix.
Add a new detail row to your Matrix, under your first and last name.
Merge the cells in your new detail row so that you have one very wide cell.
Embed (drag and drop) a new Matrix in the single wide cell in your new detail row.
Link your matrix to the Phones dataset. Set up a record filter in the matrix to limit the records to those that match the ID field in the parent matrix.
Set up the Phones as you want in the embedded child Matrix.
Repeat steps 3-7 with the Email Addresses dataset.
You don't actually need to do any grouping (unless you want to include subtotals of some kind), because you're not actually grouping anything: you're just displaying a list with embedded sub-lists.