Formula to put dat within a sentence - excel

Assuming I have the following cells:
A1 - first_Name (e.g Mary) B1 - last_name (e.g Thomas) C1 - car (e.g 3) D1 - houses (e.g 1) E1 - children (e.g blank)
I want to create a formula which can auto populate into the following sentence:
Mary Thomas has car=‘3’, House=‘1’,

All 3 of below equations build the exact same output seen in photo
Option 1 =CONCATENATE(A2," ",B2," has car= ",C2,", House= ",D2,", Children= ",E2)
Option 2 =TEXTJOIN(CHAR(32),1,A2:B2,"Has Car=",C2,",House=",D2,",Children=",E2)
Option 3 =A2&" "&B2&" Has Car= "&C2&", House= "&D2&" ,Children= "&E2

Related

Excel formula to assign multiple tags to titles

I have a list 2000 titles like below in A-Col
A1: Titles
A2: 10 Facebook Marketing Ideas for Small Business
A3: 10 Fun Facts About Social Media
A4: 10 Fitness Tips for Health Life
And I have about 20 popular (singular) words from the above titles in B-Col B2:B21 that I want to assign as tags for each title in C-Col
B1: Tags
B2: Business
B3: Social
B4: Health
B5: Fitness
B6: Marketing
B7: Facebook
So for example in C2 I want to return multiple values, so title in A2 will be labeled as Marketing, Business, Facebook in C2 these are the 3 tags assigned to the title in A2.
Labelling with multiple labels can be done in different ways. The simplest way is to create a column for each label, and enter one or zero.
Another way is working with a so-called bitmap, like following example:
"Business" tag value : 1 (binary 1)
"Social" tag value : 2 (binary 10)
"Health" tag value : 4 (binary 100)
...
"Facebook" tag value : 32 (binary 100000)
Labels can be combined, simply by adding them.
As a result:
"Business+Social" corresponds with value 3 (binary 0000011).
Value 37 (binary 100101) corresponds with "Business+"Health"+Facebook".
The main question for you: do you want it to be easily readable (multiple columns) or do you prefer short communication (bitmap)?

How can I concatenate multiple fields in Excel?

What is the actual function to generate a single line output (Column I, #QR) from below fields?
+
A
B
C
D
E
F
G
H
I
1
f_name
l_name
designation
email
landline
mobile
country
web
#QR
2
John 
DOE
Senior Manager 
john.doe#gmail.com
4422688
444221
Sweden
google.com
BEGIN:VCARD\nVERSION:2.1\nFN:John Doe\nORG:Senior Manager - Google\nADR:Sweden\nTEL;WORK:4422688\nTEL;CELL:444221\nEMAIL:john.doe#gmail.com\nURL:google.lk\nEND:VCARD
There is a function "Textjoin" if you're using Excel 2019 or up:
=TEXTJOIN(" ",TRUE,A1:A2)
This would result into the string "f_nameJohn". You can look up more about this function here: https://support.microsoft.com/en-us/office/textjoin-function-357b449a-ec91-49d0-80c3-0e8fc845691c
You can also use:
=A2&B2
giving JohnDOE
Then you can do:
=A2&" "&B2
which will put a space between: John DOE
if you don't have Excel 2019 or up you can use:
=A2&" "&B2&" "&C2&" "&D2&" "&E2&" "&F2&" "&G2&" "&H2&" "&I2
or
=CONCATENATE(A2," ",B2," ",C2," ",D2," ",E2," ",F2," ",G2," ",H2," ",I2)

How to sum a reference column with a custom ordering

I'm trying to sum a column that is from an input table to link to a reference table that a user can select inputs to create a "group." I think an example is better here:
Inputs
Key Type Name Count lookup_value
1 Fruit Apple 3 1 - Apple
2 Fruit Orange 5 2 - Orange
3 Fruit Pear 6 3 - Pear
4 Veggie Broccoli 3 4 - Broccoli
5 Veggie Celery 2 5 - Celery
The user puts these inputs in, and from another screen is able to customize a group (each of the selection is from a dropdown,lets call each array of data input_column name such as input_lookup_value for our formulas). Using the following formula in a cell next to "Total Pieces of Food,"
=sumproduct(--(A1:A3=input_lookup_value),input_count)
We will get the correct answer of 14, as below.
Group Name: Food Sally Likes
Total Pieces of Food 14
Item
A1 1 - Apple
A2 2 - Orange
A3 3 - Pear
However, if the user is to put in just Celery in cell A1, the formula will not work, and the "Total Pieces of Food" will return 0, since the order does not match the Input table order. Is there another formula or way I can attack this that will return the correct count, and still allow the user to enter the list in any order?
To put what #Jeeped (with his permission) suggested in the comments into an official answer:
The formula is:
=SUM(SUMIFS(Sheet16!D2:D6, Sheet16!E2:E6, A4:A6))
This is an Array Formula, So confirm with Ctrl-Shift-Enter

Excel: Challenging formula sought for counting records

I am looking for some help with a formula. On my 'data' sheet, I have data in the format below:
A B C D E F G H I J
1 UID RecordType HCode AdmittedDate Forename Surname DOB Sex STDate RDate
2 87962 STAsses STIV1 01/01/2012 Mark Jones 13/07/1978 Male 09/12/2012
3 89658 Transfer GLSI2 01/01/2012 Alison Aitken 20/12/1956 Female 08/07/2013
4 84563 Discharge JHOP1 01/01/2012 David Beckham 09/08/1987 Male 08/07/2013
5 89654 STAsses STGE1 01/01/2012 Andrew Macbeth 27/09/1976 Male 08/07/2012
6 89867 Transfer KIND1 01/01/2012 George Deas 08/05/1989 Male 08/07/2013
7 87962 Transfer STIV1 01/01/2012 Mark Jones 13/07/1978 Male 04/03/2013
8 89654 Transfer STGE1 01/01/2012 Andrew Macbeth 27/09/1976 Male 12/08/2012
On my 'report' sheet, I have the following table set up:
B C D E F
4 HospCode RecordType Jul-12 Aug-12 Sep-12
5 STGE1 Assessments
6 Transfers
7 Discharges
8
I would like to do 2 things.
In D5, E5, F5, a formula is needed to return the number of 'STAssess' records for HCode 'STGE1' from the data sheet, which were completed in the month shown in D4 of the 'report' sheet (Jul-12). The dates for these records are in column I of the data sheet - 'STDate'.
I've tried using SUMPRODUCT which works to an extent, but I'm having difficulty bringing back records only completed in July. I need the formula to be dynamic in that it only brings back results for the month entered in D4 (so a date range built into the formula isn't doing the job).
In D5, E5, F5, I need to bring back the number of records from the 'data' sheet, which have 'Transfer' in column B (RecordType), 'STGE1' in column C (HCode) and a date in column J (RDate) which falls in the month specified on D4 of the 'report' sheet (Jul-12).
Anyone got any ideas? The data sheet is actually going to be an external .csv file which can't be manipulated. I don't mind using other hidden sheets to do any sorting that needs to be done, provided that this can be setup so that when the data is brought in, no extra work has to be done.
Thanks!
For both of your questions you can use COUNTIFS. It is easier to understand (for me) and compatible with Excel 2007 and newer.
First question:
=COUNTIFS(DATA!B:B,"STAsses",DATA!C:C,$B5,DATA!I:I,">="&D$4,DATA!I:I,"<"&DATE(YEAR(D4),MONTH(D4)+1,1))
Second question:
=COUNTIFS(DATA!B:B,"Transfer",DATA!C:C,$B5,DATA!J:J,">="&D$4,DATA!J:J,"<"&DATE(YEAR(D4),MONTH(D4)+1,1))
And these formulas can be dragged across your needed range.
Here is an example formula that you could use for the D5 cell, does that point you in the right direction?:
{=SUM(IF($B$2:$B$8=$B14,IF($C$2:$C$8=$A14,IF($D$2:$D$8=C$13,1,0),0),0))}
This is an array function so you must enter it without the {} at each end and use Ctrl + Shift + Enter to enter the formula.
If your summary table looks like
HospCode RecordType 12-Jul 12-Aug 12-Sep
STGE1 STAsses 1 0 0
STGE1 Transfer 0 1 0
STGE1 Discharges 0 0 0
And your data is in a table called Table1, then in D5
=SUMPRODUCT((Table1[HCode]=$B5)*(Table1[RecordType]=$C5)*(MONTH(Table1[STDate])=MONTH(D$4)))
I'm not sure what you mean by 'bring back', but assume you mean that you want to show it when RecordType = column C and when the RecordType = "Transfer" and the RDate is in the right month. Then
=SUMPRODUCT((Table1[HCode]=$B5)*(Table1[RecordType]=$C5)*(MONTH(Table1[STDate])=MONTH(D$4)))+SUMPRODUCT((Table1[HCode]=$B5)*(Table1[RecordType]="Transfer")*(MONTH(Table1[RDate])=MONTH(D$4)))

Spreadsheet - ordering a column twice, using different scores (from 2 other colums)

I am working on a spreadsheet - currently google docs but happy to see answers relating to other spreadsheet software.
I have a list of foods (column A - Food)
I have list1 of "scores" (column B - Score1)
I have list2 of "scores" (column C - Score2)
I would like to add two new columns, ideally ordering the food from column A according to the scores, both list1 and list2 - so one new column ordering the foods based on the score1 from column B, and the other new columns based on the score2 from column C.
An example usually helps, so here is what I have:
Food Score1 Score2
a 12 45
b 96 67
c 100 32
Now, this would be "Version 1", on the way to getting what I would like:
Food Score1 Score2 Order1 Order2
a 12 45 3 2
b 96 67 2 1
c 100 32 1 3
Or, even better, "Version 2" - use the food name in the new columns, in the right order according to scores:
Food Score1 Score2 FoodScore1 FoodScore2
a 12 45 c b
b 96 67 b a
c 100 32 a c
I suspect that getting "Version 1" is probably achievable (but don't know how to do it)
I suspect that getting "Version 2" is not possible without some sort of procedural programming?
Hope someone can help!
Cheers
Or, even better, "Version 2" - use the food name in the new columns, in the right order according to scores:
Let A2:A10 - is your food range, B2:B10 - score1 range, D2:D10 - destination range ( FoodScore1 in your example)
Works both in EXCEL and in GOOGLE-SPREADSHEETS:
=INDEX($A$2:$A$10,MATCH(LARGE($B$2:$B$10,1+ROW(A2)-ROW($A$2)),$B$2:$B$10,0))
enter this formula in D2 and drag it down
If formula will give you an error, try to change , to ; (depends on your local settings).
P.s. for score2 formula would be the same, just change ranges from score1 to score2 (i.e. $B$2:$B$10 to $C$2:$C$10)
I would start by adding a rank column, with number 1 for the highest score, number 2 for the second highest, etc.
In Microsoft Excel, assuming that the first column is A and that all the scores are unique, you could simply have a formula like
=COUNT.IF(B:B, ">=" & $B1)
in column D1, and similarly in column E for the second score.
Then if you fill column F with the ranks 1, 2, 3, ... you can simply do a VLOOKUP. Or, in this case, an equivalent solution with INDEX and MATCH - because you want to lookup the rank in column F and return the corresponding value from column A.
As you are working in a Google Spreadsheet, one would expect to see some Googliness in the solutions provided. Use this very simple, only usable in Google Spreadsheet, formula.
Formula
// FoodScore1
=QUERY(B2:D4, "SELECT B ORDER BY C DESC")
// FoodScore2
=QUERY(B2:D4, "SELECT B ORDER BY D DESC")
Screenshot
Explained
The data range of the QUERY function is simply B2:D4. Then a quasi SELECT statement is made to select only column B and ordered by column C or D, descendingly.
Reference
https://developers.google.com/chart/interactive/docs/querylanguage

Resources