Tableau create a table matrix? - matrix

I have a CSV file that looks like this. It is in matrix form where cell A1 is empty. I want to visualize this in Tableau like this
a1,a2,a3
a1,1,0.2,0.3
a2,0.3,1,0.5
a3,0.6,0.7,1
How can I build this in tableau to show a matrix?
I tried putting measure name in both the row and column field and measure values in the marks text box but i ended up with diagonal values which isn't what i want.

First structure your data in the form of a table.
A well structured CSV file for Tableau (and most tools) has a single header row that labels each column (so skipping the first cell in the header row is a problem). Then each data row that follows contains only values in each field separated by columns (so there should be no leading row labels)
Order is not significant in a relational table. The rows in a table form a set, not a matrix.
So your CSV should look something closer to
field_name_1,field_name_2,field_name_3
1,0.2,0.3
0.3,1,0.5
0.6,0.7,1
Normally, the prime use of Tableau is display an aggregated summary of the data, not to display each individual data row. So you can put measure_names on columns and measure_values on the text or label shelf to get a summary of each measure (by default a sum)
If all you want to do is to view the underlying data rows in a table for diagnostics, the easiest way is to use the view data button or menu command.
If you want to build a visualization that displays all the data (without summarizing it) in a table, you have two ways to go. The simplest is if you have a unique primary key in your data, you can place it on the row shelf to get a row in your viz for each row in your data.
If your data rows do not have a primary key, you can turn off aggregate measures from the Analysis menu, but then you'll see multiple values in each table cell. Then to get a row in your viz for each row in your data, put the calculation index() on the rows shelf and change it to discrete.

Related

Instead of selecting a column to sort a table by in a dropdown, how do I add the sorting column names in a separate column?

I have a workbook where I have displayed a table where the user can view the top 3 IDs based on a column they can select from a dropdown (Measure A, Measure B, ... , Measure H):
Now, instead of this, I want to add a separate column called Sorting Criterion to the table that would store the column names with which the respective rows of the table was sorted. So, the expected output is something like this:
How do I do this? I'm open to using Tableau Prep Builder, if needed, for intermediate steps that may be too convoluted for Tableau Desktop.
Create a calculated field that just contains the Sort By parameter. Add this calculated field to your view.

DAX: Use measure outcome to populate calculated column without recalculating measure per row

I have two tables in PowerBI. One called 'Fact_WorstInstance' contains rows of (Index,Instance). For example:
1,2
2,1
3,2
One called 'Fact_AllInstances' contains rows of (Index,Instance,Value). For example:
1,1,'Red'
1,2,'Green'
2,1,'Amber'
2,2,'Red'
2,3,'Brown'
3,1,'Green'
3,2,'Blue'
The first table is essentially a pointer to the worst entry in the second table for the given index (as categorised by some external system).
There is a slicer on which Indexes are visible to the user.
What I want to do is find the worst instance value for the highest visible Index in the 'Fact_WorstInstance' table, and then get all the Index and Value rows from the 'Fact_AllInstances' table for that Instance.
For example, if the slicer isnt filtering then (3,2) should be the active row from from the 'Fact_WorstInstance' table and this should be used to get Instance 2 from the 'Fact_AllInstances' table
1,2,'Green'
2,2,'Red'
3,2,'Blue'
from the 'Fact_AllInstances' table.
I tried to do this in many different ways, by creating a measure on the 'Fact_WorstInstance' which gives the highest visible row. And then use this measure to create a calculated column on the 'Fact_AllInstances', with 1 for worst and 0 for not worst. And then use this calculated column as a filter in PowerBI.
The measure itself gives the expected value. The problem I have is when the measure is used to create the calculated column, I cannot find a way to stop the Index being filtered based on the row of calculated column - and therefore the measure outcome changes for each row.
My measure:
Worst Entry = CALCULATE(FIRSTNONBLANK(Fact_WorstInstance[Instance],1),filter(ALLSELECTED(Fact_WorstInstance),Fact_WorstInstance[Index]=MAX(Fact_WorstInstance[Index])))
My column:
WorstColumn = if(Fact_AllInstances[Instance]=[Worst Entry],1,0)
So instead of getting the output above, I get
1,2,'Green'
2,1,'Amber' --> because for Index 2, the measure gives index 1 as worst
3,2,'Blue'
This is a possible solution you might want to implement.
First of all, calculated columns are not affected by slicers/page filters, you will need to create a measure for that, so the way your are appraching the problem won't work.
Create an additional calculated table that holds unique instances values. In Power BI, Modeling tab there is a icon for creating a New Table, where you can use an expression to produce the table.
Use this expression:
IsntancesCalcTable = VALUES(Fact_WorstInstance[Instance])
Now you have a table called InstancesCalcTable in your model.
Drag the Instance column in the InstancesCalcTable and drop it in the Instance column of the Fact_WorstInstance, this will create a relationship between InstancesCalcTable and Fact_WorstInstance via Instance. A line between both tables will be drawn in the Relationships view, double click that line and you will see the Edit Relationship window.
Make sure it looks like this:
Then do the same for creating the relationship between InstancesCalcTable and Fact_AllInstances.
You will end with a model like this:
Then you can use Index column in the Fact_WorstInstance table, in a slicer and it will filter the Fact_AllInstances table to get only the instances selected.
However if you don't have any filter all rows in Fact_AllInstances will be shown.

BIRT formatting - merge cells on specific rows

How do I merge cells for specific rows in BIRT? Something similar to using colspan when creating a table in HTML. The data is extracted from a database and returns a fixed number of rows.
Specifically I want to convert a BIRT report that looks like this:
to this:
Thank you for your assistance.
I don't know if it is possible to do this within an onCreate event for the cells.
But depending on your use case, it may be sufficient to duplicate the detail row.
Keep the cells as is in the first detail row and merge them in the second row.
Determine a condition when to merge cells and when not.
Use this as an visibility expression for the first and second detail row like this:
First row: should_merge(...)
Second row: !should_merge(...)

Cross table with two datasets (one as the row and the other as the column)

I have two datasets in my birt report :
Lesson (date)
Student (name)
and I would like to know how to create a cross table using the date (red) as the column names and name (blue) as the row names as shown below :
The cells will stay empty.
I have try to use the Cross Tab but it seems that I can only use one dataset.
For information I am stuck with the version 2.5.2. I say this in case someone writes about a practical functionality available in the later version of birt... :-)
Where both datasets are coming from the same relational data source, the simplest way to achieve this would normally be:
Replace the existing two datasets with a single dataset, in which the two original datasets are cross-joined to each other;
create a crosstab from the new dataset, with the new dataset columns as the data cube groups.

Tableau pulling one value from table

I have a table in Tableau that is based on a MTD calculation. It gives multiple values for different departs on each day of the month. This table is linked to another sheet that I click on to choose the value in the table that I want to see.
Right now I only highlight that value in the table. I want to be able to pull one specific value out and display by itself in the dashboard close to the chart.
How do you pull a value from a table and display.

Resources