Concatenate values in one row with comma as delimiter in TABLEAU worksheet - concatenation

Currently my sheet looks like:
Type | Product
A | p1
B | p2
A | p2
C | p3
I want my sheet to look like:
Type | Product
A |p1,p2
B |p2
C |p3
I want to show all products of Type 'A' in one row. To avoid duplicates 'A' entries.

You will need to create a couple table calculations to do this:
create 1 named Products:
IF INDEX() = 1
THEN ATTR([Product])
ELSE
PREVIOUS_VALUE(ATTR([Product]))+ ", "+ ATTR([Product])END
This needs to be set to compute using pane down
Then create another called Rank
RANK([Products])
Put Type, Rank (you will need to change this to discreet to put between type and product), and your original Product field into your Rows.
Right click on your "Rank" and "Product" fields in the row and deselect "Show Header"
put "Rank" into your filters and set it to only be the value of "1"
You will then need to right click on Rank and set it to Calculate using "Pane(across then down)"
Put your new "Products" measure into your text mark.
With this you should get a sheet that looks like this:

Related

How can I make a single filter on Google Data Studio for multiple columns which contain dichotomus variable?

I have a database that looks like this:
Var1
Var2
Tag 1
Tag 2
Local1
V1
0
1
Local2
V2
1
0
Local3
V3
1
0
Local4
V4
0
1
In Google Data Studio Report here; how do I put a single filter box where I can select the tag (title of the column of multiple columns) and only the rows that have a 1 in that rage of columns shows up?
The return of the filter would look like this When the filter selects Tag 1
Var1
Var2
Local2
V2
Local3
V3
And the return would look like this when the filter selects Tag 2
Var1
Var2
Local1
V1
Local4
V4
Sample data is here.
You set up an example for two columns, but in your sample you have many. Therefore, I show how to do it for two columns by selecting a number. But for the real case a parameter with a text list would be more user friendly, so they could see what they are selecting. All columns in the function are queried, so keep the costs for that in mind.
There is the need to use a parameter, lets call it tag_selected.
Create a field tag_filter with the columns you would like to select
case when tag_selected=1 then Anti-Corruption and Integrity
when tag_selected=2 then Audits
else 1
end
Finally create a filter to the table with the condition tag_filter =1

If statement across MS Excel sheets

BACKGROUND (simplified version): I’m sorting data sheets of different items for our lab. I have one sheet that lists the code number of the item (column A) with the actual name of the item (column B), for example
code | item
001 | Banana
002 | Cabbage
003 | Carrot
004 | Peach
and another sheet (labelled stocks) that lists only the code number (column A) and the amount of stock we have for that item (column B), for example
code | stock
001 | 5
002 | 6
003 | 2
004 | 7
PROBLEM: Now, these items can be sorted into 2 categories, “fruits” and “vegetables”. I can easily sort the items in the item sheet manually because I can see the actual item name, but for the stock sheet, only the code number is listed which means I would have to keep looking at the other sheet to see which item is associated with a particular code.
I already have separate item sheets for fruits and vegetables, so I have three sheets total now: fruits, vegetables, and stocks.
I was thinking of an IF statement to be placed in the stocks sheet that would indicate if the item is a fruit or a vegetable. Something like: if the code in A1 of the “stocks” sheet is present in column A of the “fruit” sheet, then print the word “fruit” in C1 of the “stocks” sheet. If not, print the word “vegetable” in C1.
My ultimate goal (what the lab is looking for) is that I would have separate item sheets for fruits and vegetables (already done) and also separate stock sheets for fruits and vegetables (to be done).
Would appreciate any help. Many thanks
VLOOKUP works well for this.
Make a third column in the stock sheet with the following formula in Cell C2 and copy it down to the cells below:
=VLOOKUP(A2,Fruits!$A$2:$B$200,2,FALSE)
This takes the value in cell A2, find the same id in the table in sheet 1 and returns the value that is given in the 2nd column of the Fruit Worksheet.
If you want the tables fruits and vegetables separate. You can use IFNA to find the id in the second worksheet as followed:
=IFNA(VLOOKUP(A2,Fruits!$A$2:$B$200,2,FALSE),VLOOKUP(A2,Vegetables!$A$2:$B$200,2,FALSE))
if the code in A1 of the “stocks” sheet is present in column A of the “fruit” sheet, then print the word “fruit” in C1 of the “stocks” sheet. If not, print the word “vegetable” in C1.
This is a simple test across the worksheet. This formula searches range A:A in the "Fruit" sheet, and if there is a match (returned as a number) it gives the first value "Fruit", otherwise it will return "Vegetable".
=IF(ISNUMBER(MATCH(A1,Fruit!A:A,0)),"Fruit","Vegetable")
However be careful with this, because if the code is wrong of not found, it will return "vegetable" by default. To get around this, use a nested IF statement which checks both sheets like so, and returns "Not found" if the code is wrong.
=IF(ISNUMBER(MATCH(A1,Fruit!A:A,0)),"Fruit",IF(ISNUMBER(MATCH(A1,Vegetable!A:A,0)),"Vegetable","Not found"))
EDIT: I've swapped the SEARCH for the more powerful MATCH since this will negate display options and still find the correct sheet.

Assign rows to category in Openrefine

I have a dataset like this, and I'm looking for a way to add a category, based on what kind of product I have.
Can I search for Apple + Orange and assign them to a category named Fruits, and similar with Milk + Wine and assign them to another category, named Drinks?
| Item | Category |
|-------|----------|
| Apple | | <-- Fruits
| Orange| | <-- Fruits
| Milk | | <-- Drinks
| Wine | | <-- Drinks
Or maybe a simpler method: find any rows containing Milk and assign them to category Drinks?
This is something you can do without code.
Filter or facet in the Item field for each value
Create a facet on the Category field
Click the edit button next to the blank value in the Category facet and type with the category you want to add.
Edit your Item facet or filter to move to the next category and repeat this process until you have categorized all yours items.
As magdmartin says you can do this using facets and edits - the solution he describes is probably the simplest approach and least error prone. However, if you prefer to do in a single step you can use GREL to test the content of the Item cell and then set the value in the Category cell dependent on the content of the Item cell.
with(cells["Item"].value.toLowercase(),w,if(or(w=="orange",w=="apple"),"Fruits",if(or(w=="milk",w=="wine"),"Drinks","")))
This is the same approach as given by Ettore Rizza above but in GREL rather than Jython.
magdmartin and Owen Stephens give good answers. Another simple way using GREL:
From the options dropdown for your 'Item' choose Edit column > Add column based on this column...
New column name 'Category' and in the expression set:
value.replace("Apple","Fruit").replace("Orange","Fruit").replace("Milk","Drink").replace("Wine","Drink")
You could keep adding .replace("whatever food","whatever category") ad nauseum

Excel Index + if + indirect

I am helping a friend with a work task he's been given and can't figure out the last part. We are given a matrix with a list of workers / users in the following layout:
Location | First Name | Last Name | Property 1 | Property 2 | Property 3 | .. | Property N
Frankfurt | Adam | Schmidt | X | | X | .. | X,
i.e. the properties are in boolean form (X to indicate 'Yes', or empty to indicate 'No').
The task is to search all users based on Location + 1 property that we are able to select from the N properties, i.e. we have a drop-down menu somewhere with all properties 1,2,..,N where we can select exactly 1 of the properties.
The output should be the format: Location | First Name | Last Name.
So, my idea was to replace the standard IF(("array for criteria 1"= "criteria 1") * ("array for criteria 2" = "yes"), ...) with the ADDRESS of the property we select, which we then transformed from text value into cell reference using the INDIRECT function.
To give an example, if we select property 1 (located in column D) in the drop-down menu, the ADDRESS function will return $D$1 as the starting field, and $D$100 as the ending field. These fields are then used inside an INDIRECT function inside the main (long) search function.
I've seen from other posts on the internet that it is possible to use SUM(INDIRECT(cell with starting cell defined&":"&cell with ending cell defined)), so I tried something similar in my function, but it doesn't seem to work.
Here is a picture of the formula & layout of the excel file.
You should organize your sheet into 3 sections:
Data set
Criteria
Result Set
Follow the steps to create the button action for Search.
Navigate to 'Developer' tab.
Click on Insert > Button.
Draw a button. The 'Assign Macro' dialog box will be displayed.
Click on Record.
Enter the macro name as 'SearchRecords' and click on OK.
Click on any empty cell. Navigate to 'Data' tab.
In the 'Sort & Filter' section click on 'Advanced'.
Select 'Copy to another location' radio button and enter the range based on data set and criteria locations.
Click on OK.
Navigate to 'Developer' tab and click on 'Stop Recording'.
Rename the button to 'Search'.
Now you can update the search criteria and click on the search button to update the results in the adjacent location.
A much easier way would be to organize your input data as follows:
This data set is Pivot friendly. You can then create a Pivot Table of the data set. Move the Location and Property fields to the Report Filter section, the Full Name to the Row Labels section and the Location to the Values section.
Please note Full Name is just a concatenated value of 'First Name' & 'Last Name'.

Excel data compare and change

I'll try to stay clear. So the problem is I want to change some data based on the cells value.
Let say the column A is the price, column B is the base value to compar with (like item001,item002), column C is the value for comparing (item001,item002,etc.) with the NEW price in column D. I would like to find the same value in column B and C, and depending if there is a match,to change the value in right row of column A to value in column D. Was it clear enough? Basicly I have 4 columns, 2 times the codes and the prices of the codes. I want Excel to find the same codes and change the price of the old to the new one. The first two columns with price and codes are much longer then the other 2 columns with new price and the data to compare won't be in the same row for sure.
Probably there is no simple solution, but would help my work a lot. I would appreciate if someone can tell which functions should I use in combination.
Sorry for being a noob, have to start learning from somewhere.
Best regards,
Endre Kalmar
So, ...
| A | B | C | D |
-------------------------
1 |price| ID | ID |price|
This is the situation you got?
In column E, put
VLOOKUP(B1; C:D; 2; FALSE)
Depending on your regional settings, the ; might be replaced with a ,
This will give you the price in column D when the value in column B can be found in column C
If it cannot be found, you get an #N/A error

Resources