The data below is in an Excel sheet. The data is sorted on Column A (Cluster) and a group of values in Column B (Town) is associated with a Cluster. In the example below, the first five towns in Column B belong to Cluster A. Similarly, the next four towns belong to the Cluster M.
The requirement is that the first Town of each Cluster should be the same as the Cluster name itself. In the example below the first town of Cluster A is A so in Column C (Check), a 1 has been displayed. For Cluster M however, the first town is not M (it is N), hence Column C has 0 in it. Subsequently, in row 8, the cluster name matches with the town name. Hence a 1 is displayed in Column C.
How do I do this using either Excel Formulas or a macro?
+--------+---------+------+-------+
| Row No | Cluster | Town | Check |
+--------+---------+------+-------+
| 1 | A | A | 1 |
| 2 | A | B | |
| 3 | A | C | |
| 4 | A | D | |
| 5 | A | E | |
| 6 | M | N | 0 |
| 7 | M | O | |
| 8 | M | M | 1 |
| 9 | M | A | |
+--------+---------+------+-------+
With your columns labelled, in C2 and copied down to suit please try:
=IF(A2=B2,1,IF(A1<>A2,0,""))
Related
I have a list similar to this one:
NO | Cat1 | Cat2 | | Crit1 | Crit2 |
---|------|------| | A | O |
5 | A | O |
3 | K | Y |
6 | K | Y |
7 | F | K |
8 | A | O |
9 | J | H |
10 | K | Y |
5 | F | T |
50 | A | O |
8 | L | E |
1 | R | D |
Based on two criteria I want a dynamic list which changes everytime the content are changed or the criteria are changed.
If criteria is A O then the list should be as below,
|List|
|----|
| 5 |
| 8 |
| 50 |
If any other criteria is selected the list will be longer or shorter and if nothing is present it is shown as a blank cell.
I have tried some MATCH and INDEX formulas but I cannot make it work correctly.
=IFERROR(INDEX(LookUpList;MATCH(0;COUNTIF(NewList;LookUpList)+IF(Cat1<>Crit1;1;0)+IF(Cat2<>Crit2;1;0);0));"")
Sorted ascending:
=IFERROR(AGGREGATE(15,7,A$2:A$12/((B$2:B$12=G$1)*(C$2:C$12=G$2)),ROW(1:1)), "")
Ordered by row:
=IFERROR(INDEX(A:A, AGGREGATE(15, 7, ROW(A:A)/((B$1:B$12=G$1)*(C$1:C$12=G$2)), ROW(1:1))), "")
Pick one formula then fill down for subsequent matches.
In a table 1, I have,
+---+---+----+
| | A | B |
+---+---+----+
| 1 | A | 30 |
| 2 | B | 20 |
| 3 | C | 15 |
+---+---+----+
On table 2, I have
+---+---+---+----+
| | A | B | C |
+---+---+---+----+
| 1 | A | 2 | 15 |
| 2 | A | 5 | 6 |
| 3 | B | 4 | 5 |
+---+---+---+----+
I want the number in second column to divide the number in table 1, based on match, and the result in third column.
The number present in the bracket is the result needed. What is the formula that I must apply in third column in table 2?
Please help me on this.
Thanks in advance
You can use a vlookup() formula to go get the dividend. (assuming table 1 is on Sheet1 and table 2 in Sheet2 where we are doing this formula):
=VLOOKUP(A1,Sheet1!A:B, 2, FALSE)/Sheet2!B1
Since you mention table, with structured references, though it seems you are not applying those here:
=VLOOKUP([#Column1],Table1[#All],2,0)/[#Column2]
I have 30 peoples waiting for result out of 10. I want to assign each of 30 peoples: 7, 8 or 10 result randomly.
Peoples in excel are:
A1:A30
Random numbers in Excel
B1, C1, D1 //Which means B1=8, C1=7 and D1=10
The random number to keep on:
E1 to E30
To get a random integer in a range, use the randbetween(start,end) function. This will produce a random integer between the start and end parameters inclusively. Since your numbers are not contiguous, you can simply index them and perform a lookup using vlookup(randbetween(startindex,endindex),...) to get a random value from the table.
Check out this Example Excel File I created.
Use the following steps to get your desired result:
List the people in column A
Create a lookup table in Columns G and H
containing your desired result values.
In your result column (column E in the example below), add the formula: =vlookup(randbetween(1,3),G:H,2,false)
Column E will now contain either the numbers 7,8,or 10 for each person.
If you want to generalize this and allow any number of different values in your result lookup table, you can change the formula in column E to: =vlookup(randbetween(1,counta(G:G)-1),G:H,2,false).
Note: The -1 is only needed if your lookup table has a header row.
This will select a random value from all non-empty rows in your result lookup table.
In the example below, I added a header row to row 1, and the people start in row 2, for clarity.
+---+---------+---+---+---+--------+---+-----------+--------------+
| | A | B | C | D | E | F | G | H |
+---+---------+---+---+---+--------+---+-----------+--------------+
| 1 | Names | | | | RESULT | | Result ID | RESULT Value |
+---+---------+---+---+---+--------+---+-----------+--------------+
| 2 | Person1 | | | | 7 | | 1 | 7 |
+---+---------+---+---+---+--------+---+-----------+--------------+
| 3 | Person2 | | | | 7 | | 2 | 8 |
+---+---------+---+---+---+--------+---+-----------+--------------+
| 4 | Person3 | | | | 10 | | 3 | 10 |
+---+---------+---+---+---+--------+---+-----------+--------------+
| 5 | Person4 | | | | 8 | | | |
+---+---------+---+---+---+--------+---+-----------+--------------+
With two sheets, I'm looking to compare columns B and C from Sheet1 to columns A and B of Sheet2. If there is a match, record the value in column A from Sheet1 in column C of Sheet2.
Specifically, what would be a formula to place in Column C on Sheet2 to calculate the corresponding value from Column A on Sheet1?
Sheet1
| A | B | C |
| 1 | 1000 | A |
| 2 | 2000 | B |
| 3 | 3000 | C |
| 4 | 4000 | D |
Sheet2
| A | B | C |
| 3000 | C | |
| 2000 | B | |
| 3000 | C | |
| 1000 | A | |
Sheet2 (desired output)
| A | B | C |
| 3000 | C | 3 |
| 2000 | B | 2 |
| 3000 | C | 3 |
| 1000 | A | 1 |
Apologies if this particular issue has already been answered. I feel like this should be very simple, but I'm just not very experienced in these types of lookups.
The easiest way is to insert a helper column in each sheet that defines a unique key.
To do so, insert a new column C in each sheet and populate it with this formula =A1&";"&B1.
Then, enter this formula in D1 (formerly C1) of sheet 2: =VLOOKUP(C1,Sheet1!$C:$D,2,0)
I have a datatable which displays records of country, state and district.
country | state | district
--------+-------+---------
ABC | A | Z
ABC | A | y
ABC | A | x
ABC | B | 1
ABC | B | 2
However, as you see in the example, the country is repeated over multiple rows. I would like to merge those into a single cell like so:
country | state | district
--------+-------+---------
ABC | A | Z
| A | y
| A | x
| B | 1
| B | 2
How can I achieve this?