Cross reference to different workbook - excel

I have two Excel files:
File1
A B
1 NameofDeal
2 Nike Man
3 Nike Woman
4 Adidas Man
5 Adidas Woman
with many more rows, and other columns that are not here relevant.
File2
A B C D
1 NameofDeal Company TaxNo
2 NIKE woman Nike 101
3 NIKE man NIKE 101
4 Adidas man ADIDAS 102
5 Reebok shorts Reebok 103
6 Nike shoes Nike 101
and other rows (but fewer than in File1) and columns that are not here relevant. Whether man or woman, the company may be the same. The Tax number is the same for Nike man and Nike woman and the same for Adidas man or Adidas woman, etc.
How do I achieve the likes of the following for the first workbook?
A B C
1 NameofDeal TaxNo
2 Nike Man 101
3 Nike Woman 101
4 Adidas Man 102
5 Adidas Woman 102
6 Reebok shorts 103

Use
=VLOOKUP(A2,'~\Two.xlsx'!TList,3,0)
should suit, provided file Two is not in use ("locked"). ~ above is a place marker for the full path and should be replaced to suit along the lines of D:\Folder1\Folder2 Care should be taken with apostrophes and final backslash.
The formula would be entered to the right of ColumnA and on the row for the first entry (here Row2), then copied down as far as required.
Note that the image does not show the full path because the files were open in the same Excel instance at the time the screenshot was taken.

Related

Trying to find clients that have ONLY bought one certain item in excel

I have two items codes 555 and 777 that are the same item (Pen). If they are the only items a customer has bought I would like to see just them. Example below
Name CustomerID Item Name Item # Desired Result
Bob 1 Tape 111
Bob 1 Tape 111
Bob 1 Pen 555
Greg 3 Pen 555 Check
Jim 4 Tape 111
Jim 4 Pen 555
Tom 7 Tape 111
Tom 7 Stapler 222
Jack 8 Pen 777 Check
Zach 9 Pen 555
Zach 9 Paper 333
Zach 9 Stapler 222
Zach 9 Tape 111
=IF(OR(AND(B1:B3,D2=555),AND(B1:B3,B2=777)),"Check","")
is what I have tried but it just marks any with 555 or 777.
use:
=IF(AND(OR(D2={555,777}),COUNTIF(B:B,B2)=1),"Check","")
If you know that the customers are sorted, you could try something like:
=IF(AND(OR(D2=555,D2=777),AND(B2<>B1,B2<>B3)),"Check","")
unless you also want to check customers who bought both 555 and 777.
AND(B1:B3,D2=555) probably isn't doing what you want. B1:B3 will always be 'true' (it's not an expression, its just a range), so that is only checking if D2=555

Bash code to struture proteomics data

I need help concerning retructuring my dataset so that I can perform the downstream analysis. I am presently dealing with proteomics data and want to perform comparative analysis. The problem is the protein ids. In general one protein can have more then 1 id and they are separated by ";". I need to print the entire line of the same protein with different protein ids. for example:-
Input file :
tom dick harry jan
a;b;c 1 2 3 4
d;e 4 5 7 3
desirable output:
tom dick harry jan
a 1 2 3 4
b 1 2 3 4
c 1 2 3 4
d 4 5 7 3
e 4 5 7 3
many many thanks in advance
$ awk 'NR==1{$0="key "$0} {split($1,a,/;/); for (i=1; i in a; i++) { $1=a[i]; print } }' file | column -t
key tom dick harry jan
a 1 2 3 4
b 1 2 3 4
c 1 2 3 4
d 4 5 7 3
e 4 5 7 3
You can trivially remove the word "key" from the output if you don't like it but IMHO having some columns with and some without headers is a very bad idea - just makes any further processing more difficult.
#!/bin/bash
read header
printf "%4s %s\n" "" "$header"
while true
do
read ids values
for id in $(tr ';' ' ' <<< "$ids")
do
printf "%-4s %s\n" "$id" "$values"
done
done
This reads the header and prints is (just slightly differently formatted), then it reads each line and prints for each of these a bunch of lines, one line for each id given in the beginning of the line. For finding the ids, the ids string is split over semicolon (;).

Sorting based on first column and highest number in third column

I have a text file that needs to be sorted, my goal is to only keep the longest sequences in each of my modules. My text file looks like this:
1 abc 35
1 def 90
1 ghi 100
2 jui 500
3 yui 500
3 iop 300
My goal is to sort unique modules (first column) by keeping highest number from column 3, just like this:
1 ghi 100
2 jui 500
3 yui 500
So far I checked the sort options but without success, I guess awk could also do it!
I tried:
sort -u -k1,1 Black.txt | sort -k3n,3
Any help would be much appreciated!
You sort them based on the third column first and later unique them by first column.
sort -r -k 1 -k3n,3 Black.txt|sort -u -k1,1
output
1 ghi 100
2 jui 500
3 yui 500

Creating pivot tables and tables with relationships

I am doing my final year dissertation research and I just gathered all the results from my questionnaire, from which I got 210 responses.
I am really struggling with Excel here, so I hope somebody can help me with this.
I am running Mac Office 2011. I have a single file which is so composed:
You are a... | You like... | Gender
participant 1 Carrot | blu, red | male
participant 2 Pear | blu | female
participant 3 Carrot | red | female
I was able to create a Pivot table of how "you are a...", like so:
Carrot | 2
Pear | 1
Total | 3
I was also able to convert this total in percentage, by right clicking in the cell and selecting
Field settings > options > Show data as > % of total.
(by the way, there is a way to add another column with percentages next to the original numbers)
Anyway, my issues are the following:
1) how can I see ho many carrots and pears replied to the gender? Something like
Male | Female | Total
Carrot 1 | 1 | 2
Pear 0 | 1 | 1
Total 1 | 2 | 3
2) Also, how many participants liked blue given that the field is single and contains all the values?
ps. all the data is already consistent as apart from a few fields, questions were multiple choice selection
Thank you very much for those who will help!

How do I specify tables in my Markdown document using pandoc syntax?

I have a markdown document I'm processing with the pandoc tool to generate HTML and PDF documents. I'm trying to include a table in the document. Regular markdown doesn't support tables, but pandoc does. I've tried copy-pasting the definition of a table from the pandoc documentation into my source document, but when running it through the pandoc program the resulting document is all crammed into one big table.
Can anyone show me a pandoc table that renders properly?
# Points about Tweedledee and Tweedledum
Much has been made of the curious features of
Tweedledee and Tweedledum. We propose here to
set some of the controversy to rest and to uproot
all of the more outlandish claims.
. Tweedledee Tweedledum
-------- -------------- ----------------
Age 14 14
Height 3'2" 3'2"
Politics Conservative Conservative
Religion "New Age" Syrian Orthodox
--------- -------------- ----------------
Table: T.-T. Data
# Mussolini's role in my downfall
--------------------------------------------------------------------
*Drugs* *Alcohol* *Tobacco*
---------- ------------- ----------------- --------------------
Monday 3 Xanax 2 pints 3 cigars,
1 hr at hookah bar
Tuesday 14 Adderall 1 Boone's Farm, 1 packet Drum
2 Thunderbird
Wednesday 2 aspirin Tall glass water (can't remember)
---------------------------------------------------------------------
Table: *Tableau des vices*, deluxe edition
# Points about the facts
In recent years, more and more attention has been
paid to opinion, less and less to what were formerly
called the cold, hard facts. In a spirit of traditionalism,
we propose to reverse the trend. Here are some of our results.
------- ------ ---------- -------
12 12 12 12
123 123 123 123
1 1 1 1
---------------------------------------
Table: Crucial Statistics
# Recent innovations (1): False presentation
Some, moved by opinion and an irrational lust for novelty,
would introduce a non-factual element into the data,
perhaps moving all the facts to the left:
------- ------ ---------- -------
12 12 12 12
123 123 123 123
1 1 1 1
---------------------------------------
Table: Crucial "Statistics"
# Recent innovations (2): Illegitimate decoration
Others, preferring their facts to be *varnished*,
as we might say, will tend to 'label' the columns
Variable Before During After
--------- ------ ---------- -------
12 12 12 12
123 123 123 123
1000 1000 1000 1000
----------------------------------------
# Recent innovations (3): "Moderate" decoration
Or, maybe, to accompany this 'spin' with a centered or centrist representation:
Variable Before During After
---------- ------- ---------- -------
12 12 12 12
123 123 123 123
1 1 1 1
-----------------------------------------
# The real enemy
Some even accompany these representations with a bit of leftwing
clap-trap, suggesting the facts have drifted right:
------------------------------------------------------
Variable Before During After
---------- ----------- ---------- -------
12 12 12 12
-- Due to
baleful
bourgeois
influence
123 123 123 123
-- Thanks
to the
renegade
Kautsky
1 1 1 1
-- All a
matter of
sound Party
discipline
-------------------------------------------------------
Table: *"The conditions are not ripe, comrades; they are **overripe**!"*
# The Truth
If comment be needed, let it be thus: the facts have drifted left.
------------------------------------------------------------------------
Variable Before During After
---------- ------------- ---------- ----------------------
12 12 12 12
(here's (due to (something to do
where the rot lapse of with Clinton and
set in ) traditional maybe the '60's)
values)
123 123 123 123
(too much (A=440?)
strong drink)
1 1 1 1
(Trilateral Commission?)
--------------------------------------------------------------------------
Table: *The Decline of Western Civilization*

Resources