How to Combine Multiple Tableau Columns - sql

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.

Related

MS Access/SQL--Transitioning Columns to Rows for Dynamic Data

I have a document list that is updated periodically. The list may have up to 5 associated doc numbers associated with it. I need to generate a report that will have the primary document listed and the other 'sub documents' listed as well.
I basically need a table as show in the picture. I attempted a UNION, but if the data is dynamic, I would also continually need to update the query.
Any help or direction with this concept would be greatly appreciated.
I do not see other solution but read the recordset row by row and insert the data into new table. PIVOT would not work in this case.

Searching for value in a linked table in power pivot

I have a PowerPivot table that has a column of IDs and a linked table that contains a set of specific IDs that I want to use to create an indicator variable which I can use to sort on in existing tables and charts. Essentially I want:
If the value in column EpisodeID is found anywhere in LostEpisodes[LostID], then return the value "1", otherwise "0".
LostEpisodes is the linked table and LostID is the column that contains the subset of IDs I want to be able to sort on.
I have tried using =IF(VALUES(LostEpisodes[LostID])=[EpisodeID],1,0) but got an error. Is my syntax wrong or should I be using a different approach? Seems simple enough, but I am new to PowerPivot and DAX.
Thanks
OK - So I have found an answer that works and wanted to share. Others may have more elegant solutions, but this worked. This is where I miss MATCH.
I have a linked table called LostEpisodes which contains 2 columns, EpisodeID and Lost (all contain the value of 1 as they are all lost episodes). For my purposes I am manually entering the episode IDs as there are only a few. EpisodeID is also in the main table and is the column I am matching on.
I started with one new column labeled LostLookup with the following formula:
=LOOKUPVALUE(LostEpisodes[Lost],LostEpisodes[EpisodeID],[EpisodeID])
I then created a new column with the following formula:
=if(ISBLANK([LostLookup]),"NotLost","Lost")
This creates the indicator variable I can now use in pivot tables and charts. I have tested it and it works great.
Hope this makes sense!

Create table without omitting empty rows?

I have a short question but no reproducible sample as I simply use the standard function for now.
I want to use SQL's CREATE TABLE function. However, I want the table to display rows even if there are no data points for that specific ovbservation. Currently, whenever there is no data for a certain row, the whole row gets omitted. Ideally I'd like it to still display the row for that specific date, and just have empty cells wher ethe data is missing.
This is important because I need the table to be of specific size, even if data is missing.
One idea I had was to include a WHERE ROWNUM statement, which refers to a materialised view or table of exactly the size I want the table to be in. Is this possible? Any other solution is welcome.
Create table first of all.
use insert statement to insert all the required rows at once (empty rows with only date, or rowindex)
'View' idea is not better, because you have to show those record (empty rows to enter data perhaps) to user, so if user enters data in 5th rows, you will not be able to add 5th row in table prior to first 4 rows.

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.

Visually representing a denormalized dataset in SQL reporting services

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.