Mapped lookup in excel without duplication - excel

I have a very somewhat complicated question (at least to me ) and I'm hoping someone will be kind enough to help. I hope my explanation is good enough
I have a mapping table like below, we have multiple elements b mapped to element a
| Element a |Element b|
|---------------|-------- |
| B10 | 212010 |
| B101 | 212010 |
| B102 | 212010 |
| B103 | 212010 |
| B104 | 212010 |
| B301 | 111030 |
| B302 | 111030 |
| B303 | 111030 |
| B304 | 111030 |
|---------------|-------- |
Each element in the above table will have a value in another table:
| Element A | Value |
|-----------|-------------|
| B10 | 1,000.00 |
| B101 | 2,000.00 |
| B102 | 6,000.00 |
| B103 | 1,000.00 |
| B104 | 10,000.00 |
| B301 | 1,000.00 |
| B302 | 2,000.00 |
| B303 | 6,000.00 |
| B304 | 1,000.00 |
|-----------|-------------|
| Element B | Value |
|-----------|-------------|
| 212010 | 20,000.00 |
| 111030 | 10,000.00 |
|-----------|-------------|
I have to compare the value of the corresponding elements above using the mapping table, I'm looking for a solution that looks like the table below -
Steps:
Compare the value of each element side by side without duplicating element b
if possible put a box around each mapped element and value
I understand it may only be possible to the above using only VBA macros, but a similar solution using only excel formula will be very appreciated.
The solution should be compatible with Excel 2003.
Thank you very much

Insert a column after element a and insert formula:
=VLOOKUP(A2;$F$2:$G$7;2;FALSE)
$F$2:$G$7 should refer to the sheet/range of your values
the column after element b should contain the formula:
=IF(C2<>C1;VLOOKUP(C2;$F$2:$G$7;2;FALSE);"")
Then put a conditional format in for the border based on the cell in d column being empty or not.
Go to conditional formating and select "use formula"
type in formula:
$D2<>""
And select the tab border to select top border.

I would do this by sql query in excel if you have these tables in different sheets you can join them.
In sql after select statement you can type Distinct and this will delete the duplicates.

Related

Count matches of entire record in two separate tables - excel

Ive been trying to find a formula which would count me the match between two tables (like inner join) in excel.
I have a table1 with columns(ID,UserName,Function) and table2 (UserName,Function, etc...) need to count an explicit matches of table1(UserName&Function) and table2(UserName&Function)
tried sumproduct(--(table1[UserName:Function]=table2[UserName:Function]) but it seems like it compares it column by column and returns incorrect value, i tried to concatenate those columns within sumproduct, but still doesnt work.
Is it possible to make it in one formula or shall i build udf with sql query?
Would it be possible to return the records and list it as an array by using FILTERXML formula?
sample data:
table1:
| ID | UserName | Function |
| -- | -------- | ----------|
| 1 | oopz | FCA4001 |
| 2 | oopz | FCA4002 |
| 3 | arronT | FCA4001 |
table2:
| UserName | Function |
| -------- | ----------|
| randalO | FCA4001 |
| oopz | FCA4001 |
| arronT | FCA4005 |
Thanks in advance!:)

How to count rows between sheets with repeated primary key

I have an excel file with several sheets. I need to count 'Function' rows (non empty) by searching for a primary key. The problem is that in a sheet I have the primary key repeated more times and the corresponding column (that i want to count) has a description never the same and sometimes is empty.
First sheet
| PrimayKey| Function |
|:---------|:----------------:|
| APP0001 | Administrator |
| APP0001 | user |
| APP0001 | viewer |
| APP0001 | |
| APP0051 | user |
| APP0067 | |
| APP0067 | not |
| APP0067 | free |
| APP0067 | |
Other sheet
| Primay Key | N°_Function |
|:---------- |:-----------:|
| APP0001 | 3 |
| APP0051 | 1 |
| APP0067 | ??? |
N°_Function is what I'm looking for. So, for each APP00.. on second sheet excel must search on first sheet this key and, summing the functions, type them on second sheet.
As I've told on first sheet there are empty function cells.
I want an interactive file so I can't use a PIVOT but I need a formula that communicate between sheets. The formula must be written on the second sheet.
For example, how do you print a solution for code APP0067?
Thanks to everyone that will try

I want to count IF both condition are true Logically count by AND excel

I have two Columns both are categorical columns. Like Age_group and Engagement_category. And I want to get count no. of each engagement_category in each Age_group.
This is like GROUP BY function in SQL.
| Engagement_category | Age_group |
|:-------------------:|:---------:|
| Nearly Engaged | 21-26 |
| Not Engaged | 31-36 |
| Disengaged | 36-41 |
| Nearly Engaged | 21-26 |
| Engaged | 21-26 |
| Engaged | 26-31 |
I tried Excel COUNTIFS function but it is showing the count of each unique value in the criteria range that I have provided.
Expected OUTPUT is something like this.
| Age_group | Engaged | Nearly Engaged | Not Engagaged | Disengaged |
|:---------:|:-------:|----------------|---------------|------------|
| 21-26 | 1 | | | |
| 26-31 | | | | |
| 31-36 | | | | |
| 36-41 | | | | |
| 41-46 | | | | |
| 46-51 | | | | |
Thanks!
Use COUNTIFS function, see document: https://support.office.com/en-us/article/countifs-function-dda3dc6e-f74e-4aee-88bc-aa8c2a866842
Please try:
=COUNTIFS(B:B, "21-26", A:A, "Engaged")
Try inserting a pivot table:
Highlight the source data which is the 2-Column table including headers, go to Insert tab and click the Pivot Table button, set up the Rows, Columns and Values column as below:
The key is to drag the Engagement_Category to both Columns and Values field.

Return unique column headers matching criteria

Consider the following data below:
| 1st | 2nd | A | B | C | D | E | F | G | H |
|-----|-----|---|---|---|---|---|---|---|---|
| y | x | | | 1 | | | | | |
| y | x | | | 1 | | | | | |
| y | x | | | | 1 | | | | |
| | x | 1 | | | | | | | |
| y | | 1 | 1 | 1 | | | | | |
| y | x | | | | | | 1 | | |
| y | | | | | | | | 1 | |
| | x | | | | | 1 | | | |
| | x | | | | | | | | 1 |
| y | x | | | | | | | | 1 |
What I wish to do is to return all column headers (from A to H) that meets the following condition: it should have a value of 1 that is both aligned with a y and x value from the first two columns.
I already have a working array formula to do this, which is as follows:
{=INDEX($C$1:$J$1,SMALL(IF(($A$2:$A$11="y")*($B$2:$B$11="x")*($C$2:$J$11=1),COLUMN($C$1:$J$1)-COLUMN($B$1)),ROW(1:1)))}
However, while I drag this down, it returns two C values and one for D, F and H.
This is since there are two 1's under header C that meets the said condition. What I want is to return unique values, so C should only be returned once. I tried to make use of MATCH and additional COUNTIF instead of the SMALL function, but it is returning an error, and the 'Evaluate formula' feature of Excel isn't helping. Below if the erroneous formula I experimented with:
{=INDEX($C$1:$J$1,MATCH(0,IF(($A$2:$A$11="y")*($B$2:$B$11="x")*($C$2:$J$11=1),COUNTIF($N$1:N1,COLUMN($C$1:$J$1)-COLUMN($B$1))),0))}
A workaround I am currently doing is to make my first formula a "helper column" and then create another formula based from the first formula's result to return only the unique values. However, the double array formula is heavily affecting the efficiency of Excel's calculation due to the huge volume of data I'm dealing with.
Any help/suggestions will do please (no VBA please, since I believe it's not needed here). Thanks!
Insert a helper row. I did it just under your header row before your data. In this row you check to see if there is a 1 that lines up with an x and a y. I assumed this to be non blank, but if its specific values change the formula from <>"" to ="y" or =134 as the case may be. Place the following formula under your first column header you are interested in and copy right.
=--(0<SUMPRODUCT(($B$3:$B$12<>"")*($C$3:$C$12<>"")*(D3:D12=1)))
Then where you want to generate your list in a column without space and sorted in the order the appear in from left to right in the headings, use the following formula and copy down as required:
=IFERROR(INDEX($1:$1,AGGREGATE(15,6,COLUMN($D$2:$K$2)/$D$2:$K$2,ROW(A1))),"")
The above formula put in a blank value when no column heading applies are you have copied the formula down beyond the number of applicable columns.
The above formulas are based on the proof of concept image below. Adjust ranges to suit your needs.
Have you tried without the use of an array formula? I don't know how large the data actually is. But, this might be what you are looking for:
=IF(COUNTIFS($A:$A,"y",$B:$B,"x",C:C,1)>0,C1,"")
Assuming column A is "1st" and "H" is your last column at colunm J. Try pasting the formula at "K1" and drag it to your right until "S1".

Kind of group by in Excel without VBA

I need another transformation help in Excel
| A | B |
---| ----|--------|
1 | ID | Course |
2 | 1 | A1 |
3 | 1 | A2 |
4 | 2 | A1 |
5 | 3 | A2 |
I want to have a kind of group by, i.e.
| A | B | C |D | ...
---| ----|---------|---------|---------|----
1 | ID | Course1 | Course2 | Course3 | ...
2 | 1 | A1 | A2 | | ...
3 | 2 | A1 | | | ...
4 | 3 | A2 | | | ...
Any ideas? Is it possible without VBA macro?
I believe that the following link on removing duplicates from column would suit your needs (in your case you would do it horizontally).
http://www.get-digital-help.com/2009/03/30/how-to-extract-a-unique-list-and-the-duplicates-in-excel-from-one-column/
Per your reply to Robert, if you want to do it without VBA, try this... Select all cells in the first column. Copy and paste them into the first column of another worksheet. Use Excel's Remove Duplicates function on the pasted data. Then use INDEX functions in the columns to the right in order to pull the first, second, etc values matching that first column value.

Resources