Displaying only 1 row for duplicated data in tableau table - tableau-api

I have a table that displays 8 columns. Due to the way the data source is structured (I cannot change this) it sometimes means one or more of the columns will be the same across two rows.
I need to filter to show only one row of data. This is based on "email', so if an email has more than 1 row, I want one of the rows. If the other columns are the same or not doesn't matter.
I don't need to combine anything, and I don't care which row is displayed, I just need to remove one of the duplicated rows.
Replace this:
Place orderid email item name date
a 1 a#a.com b c 1/1/11
a 1 a#a.com d c 1/1/11
With this:
Place orderid email item name date
a 1 a#a.com b c 1/1/11
Or this:
Place orderid email item name date
a 1 a#a.com d c 1/1/11
Any help would be much appreciated! I had a go with LOD calculations and I couldn't make that do what I wanted (that may well be me not understanding how to use them properly, though).

Given your example, it appears the difference is within the [item] field. You can create an index calculation on it and filter for value of 1.
index()
Set the index to discrete and compute using the [item] and filter for only 1. You can hide the field if you don't want it to appear by deselecting Show Header.

If you want to show the first row per email, regardless of what's in the other fields, try the following:
Create an [Index] calc field using INDEX().
Add [Index] to rows shelf and change to discrete.
Edit the table calc for [Index], select 'Specific Dimensions' and restarting every email (dropdown menu). All of the checkboxes should be ticked by default.
Notice how the index is not restarting for each email as expected. To correct this, drag email checkbox to the top position.
From here, filter [Index] = 1 and hide index column from view.

Related

Dynamically render multiple columns based on a drop-down list

I have a table in tableau with say 4 columns (Say Employee ID, Name, Address, Email).
I want to provide the users an option to select single/multiple columns from a drop down list (assume in the drop down list we have columns headers, Customfield1, Customfield2.....,Customfield10) which would be added to the table as a separate columns.
Say for Instance if the user selects CustomField1, CustomField2, CustomField3 from the drop-down list then the table should have in total of 7 columns (4 Emp fields + 3 Custom Fields)
Though I stated a simple requirement, my idea was to extrapolate that to something complex.
I think some version of this could be done, albeit in a hacky way. What you're looking for is 'Dynamic Parameters.' They don't technically officially exist in the product, but can be created with the combination of parameter and calculated field.
Here is a link to a method on such creation.
The idea here would be to re-order columns in a custom manner. Each calculated field would have to have its own logic for which dimension it was to display when a user selected a parameter. (ie: With parameter selection A Column 1 goes to [Name] and Column 2 goes to [Address], and with parameter selection B Column 1 goes to [Address] and Column 2 goes to [Name].) The caveat here is that each potential layout would need to have the same number of columns - there is not a way to add columns dynamically. Consider that each column is represented here with a calculated field.
Good luck on it.

Count of group dimensions item in Tableau

I'm fairly new to tableau and I'm having the following issue. Below is a sample of the data I'm using.
Customer No | Item
___________________
1 A
1 B
2 A
3 A
4 A
4 B
5 B
6 A
I'm trying to get a count of how many customers bought Item A and B. So far I tried doing a separate group by combining A and B but I get the total result of 8. I also tried doing a calculation and I'm getting the same result of 8. Can someone please point me to the right direction on how to get this result. Thanks!
This is the result I'm trying to get:
Item| Count
A 5
B 3
A and B 2
I recreated your exact dataset and pasted it into Tableau so you could see a couple of examples.
Here's how you can see the number of customers who purchased an individual item, plus the number of customers who purchased both items.
Your calculation will be:
IF { FIXED [Customer No]: COUNTD([Item]) } = 1 THEN
[Item]
ELSE
'Both A and B'
END
And you'll need to set your view up to look like this:
Below are ways you can see when both items were purchased.
Boolean OR
The calculation you'll want to use is:
ATTR([ITEM]) = 'A' OR ATTR([ITEM]) = 'B'
And you'll want to set up your view to look like this:
A, B or Both
If you would like a bit more specificity in your result, you might try:
IF ATTR([Item]) = 'A' THEN
'A'
ELSEIF ATTR([Item]) = 'B' THEN
'B'
ELSE
'BOTH'
END
Replacing the previous calculation with the new looks like this:
More than 1 item
If the specific items purchased don't matter, you could use this logic.
COUNTD([Item]) > 1
Replacing the previous calculation with this one would look like:
More than 1 Item using a window function (probably overkill)
The calculation you'll need to use is:
WINDOW_COUNT(COUNTD([Item]))
Because this is a Window function, we'll need to specify how it's calculated across our dimensions. To do this click the down arrow on the right-hand side of the pill and select Edit Table Calculation...
You'll then need to set these settings:
I'll add the calculation we created in the first example ([A and B]) to the filter shelf and select True. That should give you something that looks like:
More than 1 item using a Level of Detail expression
The calculation for this example is:
{ EXCLUDE [Item]: COUNTD([Item]) }
You'll view should look like:
As you can see Tableau is quite flexible. Hope these examples were helpful!
You might want to use Tableau’s set feature to approach problems like this.
For example, right click on the field [Customer No] in the data pane (i.e. left sidebar) and choose the “Create Set” command. Click “Use All” at the top of the set panel and then click the Condition tab. Define the set using the condition MAX([Item] = “A”). Name the set “Customers who bought A”.
Similarly, create a set of customers who bought item B. You can then select both sets in the data pane, and create a combined set to be the intersection, that is, customers who bought both an item A and an item B.
You can think of a set as either a mathematical set of the members of a field that belong to the set (i.e. a set of customer ids) or as Boolean function defined for each data record in the data source indicating whether that data record is associated with the set (i.e. a Boolean function that operates on transactions to say whether the associated customer ID is in the set. A key to keep in mind for the condition formulas used here is that the condition is an aggregate formula, operating on a block of data records for a customer ID to determine whether the customer ID is in the set.
Once you have defined your sets of interest, you can use them in many ways - in calculated fields, as filters, as dimensions on shelves in a visualization, in set actions, to combine with other sets ...
To define a measure that counts the customers in a set, create a calculated field such as “[Num A Customers]” as COUNTD(if [Customers who bought A] then [Customer ID] end) Do the same for whatever other sets you are interested in. Then you can use those measures (probably with Measure Names and Measure Values) to make your viz.

Google Sheet: Pick max date out of row

Assume: in a google sheet the attendance to courses is logged with crosses.
Goal is to get the last attendance date of a person and add 6 months to it. ( course needs to be followed every six months ).
I've tried to retrieve the date of the last course in one column and add the +6months immediately and tried to have the +6 months in the second column, but I didn't succeed in both attempts.
See this link for example google sheet: https://docs.google.com/spreadsheets/d/10DG2I4VgTlOHJ5TG0qH4pJ5hJ9zsYuJCgRzEtuiTE60/edit?usp=sharing
=lookup("x",$B4:$F4,B$2:F$2)
Enter this formula in cell G4 and copy down the rows.
This formula looks for "x" (the attendance indicator) in cells in row 4 (columns B to F) - it's looking for the last instance. Then it returns the cell value from row 2 (the course date) of the relevant column.
=EDATE(G4, 6)
Enter this formula in cell H4, and copy down the rows.
This is pretty straightforward. It takes the date obtained from the lookup formula and adds 6 months.
Note that the lookup formula references column F. That's because as you create more courses you'll want the formula to automatically include them. So in cell F1, type something like "Don't use this column" - and then don't use that column!
Now when you add a new course, insert a new column to the left of the column headed "Don't use this column". This will ensure that the range in the lookup formula will expand to include the new column/course, and your latest attendance date will be updated automatically.
BTW, there's no guarantee that the date of the next course is a working day.

Transpose columns in another sheet to rows via Data > Validity dropdown

I have a collection of addresses on one LibreOffice Calc sheet (7 columns, 1st name, 2nd street and so one) and want to create an invoice template on another sheet.
I know how to retrieve and transpose a known row - the solution on this other question explains that: Transpose column on one sheet to row on another, with linking
However, this does not seem to work if I use Data > Validity to fill the first cell in the address area (7 cells below each other).
What I am basically trying to accomplish is a dropdown in the first cell where I select the name and it automatically retrieves the address from the other sheet into the cells below.
Is this possible or am I overthinking here?
I suggest:
Name the data in your first column (eg CName)
Name your array of data (eg Clients)
Set the Source for Validity Criteria to CName
Assuming the validation is in A1, in A2 and copied down to suit:
=VLOOKUP(A$1,Clients,ROW()-0,0)
The -0 is not required if the validation is in Row1 but is where an offset should be made if not.

Is it possible to create a row that spans all columns of a Matrix in SSRS 2008?

Is it possible to have add a row to an SSRS 2008 Matrix that spans all of the matrix's columns?
This crude diagram shows roughly what I'm looking for:
The basic idea is that each line item is a person, and each column is a field in a form for that person. The fields themselves are dynamic (and implemented as column groups on the matrix). Additional column groups are included to append non-dynamic form fields, like the time the record was entered and who entered it. Under each person's record is a comments field, which should span all of the form fields above it.
At the moment I have the matrix embedded in another tablix, with the name and fields in the matrix and the comments in the parent tablix. This works for the data (each instance of the matrix ends up being one row), but the header repeats too often (once per person) because it's attached to the matrix. The only thought I have as to how to fix this is to create another matrix in the parent tablix with the same grouping and use it to display the headers... But this will require quite a lot of manual synchronization to keep the two matrices the same.
Edit: The key problem here is making the second row span multiple column groups.
Here's what you can do:
Select the column grouping you want to add above and right click and select
Add Group... Parent Group...
Group the column by something that will not aggregate the data. You'll have to select a field from your dataset to group by so that it creates an overlapping column grouping.
Check the Add group header box
You should now see something similar to this:
Now you just need to move the Value1 field and it's header over under the new column to the right beyond the matrix dividers. Once that's done, simply delete the ungrouped column where you just copied Value1 from and be sure to select Delete columns only checkbox.
Your finished product should look like this:
It is possible - And the above answers are partial answers leaving out one key step: Merging the cells of the child row.
First, right click on your grouped row, then select Insert Row -> Inside Group - Below and you will get two rows with the cells aligning on the columns
Second, ctrl click all the cells in your new row (ie row without the data) then right click on one of the highlighted cells, and then select Merge Cells.
Now you have the table you like. To add a value to the new row: first right click your new (multi column) cell,select Create Placeholder, and then add the dataset item you desire to the placeholder.
[Edit]
After several attempts, I'm going to say this isn't possible in SSRS. The best I could come up with is a group footer that spans columns 1,2, and 3, but not the User column.
[Original Response]
I recently did something similar to this.
First, what tool are you using to create SSRS reports? (I used SQL Server Business Intelligence Development Studio)
You'll want to create a row group (grouped on Person)
Append a row to your table in "Design" view (Right click, "Insert Row --> Inside Group - Below").
Add an expression to the row that pulls the value for your "Comment" column (=Fields!Comment.Value).
Let me know if that helps...
Try adding in you column group "header" with a grouping expression of (1=1). Then a detail field will need to be defined. If you define the other group with correct data then the "header" will stretch across all details columns. You may need to merger depending on other options.
The easiest way to do this is to create a Tablix with only one column, and your row grouping.
Then, you create two rows inside this group.
In the first row inside the group, you insert a Matrix, wich you can then subgroup as you prefer.
I just had a similar problem, and this was my solution.
I banged my head against the wall for a lot of time, until i realized the solution to my problem wasn't "making a cell span multiple column groups", but "making a cell split into multiple column groups".
You can accomplish the goal by using a subreport for each person. The subreport will receive the employee id and create the hierarchy for you. Make sure your subreport column widths match the widths of the parent report.