Can you normalize data with embedded sections in excel? - excel

I was provided with some data in excel that I'm trying to transform to make it filterable. The data is in a specific order and looks like this:
Group ID RowType Name
1 Section Name1
1 Row AAA
1 Row BBB
1 Row CCC
1 Section Name2
1 Row DDD
1 Row EEE
2 Section ...
I want to take the name of the Row Type "Section" and transform it into a constant in it's own column. The final product would look like:
Group ID Section RowType Name
1 Name1 Row AAA
1 Name1 Row BBB
1 Name1 Row CCC
1 Name2 Row DDD
1 Name2 Row EEE
2 ...
I feel like this has probably be done but I haven't been able to put together the right terms to search... Any help would be appreciated.

Related

Excel : Automate COUNTIF (based on another table)

I have a table that looks like this:
name nation
aaa ESP
bbb FRA
ccc ESP
ddd BEL
eee FRA
fff ITA
I have another table with :
country count
ESP -
BEL -
FRA -
ITA -
I would like my "count" column of the second table to count how many instances I have of that nation in the first table.
So that I get :
country count
ESP 2
BEL 1
FRA 2
ITA 1
I could enter in each cell of the "count" column:
COUNTIF('my 1st table nation column',"name of the targeted country")
The thing is I have 150 countries and I can't possibly edit all the country codes in each and every cell of the "count" column.
I also tried this workaround:
I selected the first cell of "count" and then highlighted the whole column. Then I typed:
COUNTIF('my 1st table nation column',"name of the country of the first country cell")
This way, I expected each cell of the "count" column to refer to the name of the "country" of its table row.
But it didn't work.
Is there any other way (with a formula, not VB) I can automate the process so that each "count" cell reads its "country" and swipes through the "nation" column and count how many instances there are ?
Thank you.
=COUNTIF($B$2:$B$7,"="&D2)
name
nation
country
count
aaa
ESP
ESP
2
bbb
FRA
BEL
1
ccc
ESP
FRA
2
ddd
BEL
ITA
1
eee
FRA
fff
ITA
Use a Pivot Table, field nation into rows section and field name into values section.
That way you can make a list of unique countries and count how many instances of each you got in like 3 seconds....
Create a PivotTable to analyze worksheet
data
No need of VBA.

lookup value in Excel

I have 2 table.
Table 1
ID Name
1 AAA
2 BBB
3 CCC
Table 2
ID Name
1 AAC
2 BBB
4 DDD
As output, I would like to to find out -
when the ID matches between 2 tables do we have the same Name there, if so the Output should be Name Match or Name mismatch. Else if the ID is not found between those 2 tables, the output should be "ID Not found"
Expected result -
ID Name Result
1 AAA Name mismatch
2 BBB Name match
3 CCC ID Not found
Anyone knows which query I should use in Excel to get the expected result!
use:
=IF(ISNUMBER(MATCH(A2,E:E,0)),IF(COUNTIFS(E:E,A2,F:F,B2),"Name Match","Name Mismatch"),"ID Not Found")
Or this shorter formula:
=IFERROR(IF(VLOOKUP(A2,E:F,2,FALSE)=B2,"Name Match","Name Mismatch"),"ID Not Found")

Getting a modified range of cells

I need to apply a function to a range of cells and then getting the modified version of this range.
I need to apply LEFT(A1;FIND(" ";A1&" ")-1) to a range (A1:A6) and get the range back so that =SUMIFS(B1:B6;A1:A6;"AAA") works.
Actual problem:
A company sells drugs and they want to know the total sales of a specific drug sold.
A | B
1 AAA tbl 20x50g | 3
2 AAA tbl 90x50g | 4
3 BBB 10% raz 1ml | 1
4 BBB 2% raz 1 ml | 8
5 BBB tbl 12x2,5 | 1
6 CCC vet 48x1kg | 7
On the next list is a list with only the "generic" name:
C | D
1 AAA | ?
2 BBB | ?
3 CCC | ?
I need to get the values in D1.
So far I have came to:
=SUMIFS(B1:B6;A1:A6;LEFT(A1;FIND(" ";A1&" ")-1))
This will compare everything in A1:A6 with the first company (AAA). If it gets a match (A1, A2) it will take the value from the B1:B6 and the answer would be 7.
But I need to apply the "get first word" function
LEFT(A1;FIND(" ";A1&" ")-1)
to the range A1:A6
EDIT:
My bad. It appears I was trying to reinvent fire by spiting water on wood.
The problem was elsewhere.
The values in B were being produces through
=IF(AB34=0;" ";AB34*$Y34)
and the TRUE clause (" ") messed up the math.
You would use the SUMPRODUCT with LEFT(FIND()):
=SUMPRODUCT((LEFT($A$1:$A$6;FIND(" ";$A$1:$A$6 & " ")-1)=D1)*$B$1:$B$6)

Excel file - Keep the most recent for each ID

I have an excel file with this kind of data:
ID1 XXX YYY 22/11/1987
ID1 ZZZ AAA 23/11/1987
ID2 ZZZ AAA 23/11/1987
In that case, I would like to keep, for each ID (other fields might be differents), the most recent one, which would lead me with:
ID1 ZZZ AAA 23/11/1987
ID2 ZZZ AAA 23/11/1987
Thank you for your help
Assuming your data is in four columns (A:D) you might apply an array formula (CSE entry) such as:
=MAX(IF(A:A=A1,D:D))=D1
(although it would be preferable to restrict the number of rows to something manageable) in Row 1 and copied down to suit, to identify (by FALSE) rows to be deleted with Filter.

Sum the value in one column based on the value in another column - excel 2013

I have 3 Columns, B,C and D.
Columns B,C,D will be updated periodically and the number of rows will be increased day by day.
Columns B contains NAME, C contains Quantity and D has Date value.
Name Qt Date
SSS 20
SSS 30
NNN 50
PPP 40 13-Jul-15
PPP 20 13-Jul-15
AAA 20
CCC 100
GGG 300
FFF 200
BBB 50 28-Aug-15
AAA 20
GGG 100
BBB 30
JJJ 50
BBB 30
FFF 50
FFF 25 24-Aug-15
CCC 75
JJJ 30
FFF 50
JJJ 36 24-Aug-15
FFF 50 24-Aug-15
I need the result as below.
Name Qt
AAA 40
BBB 30
CCC 175
FFF 300
GGG 400
JJJ 80
NNN 50
SSS 50
Rows with date field(column D) having a value should be omitted from adding.
Name field can contain any name and future names can vary from current names.
The Result can be in the same sheet or in the different sheet.
This may not meet your exact needs but it should get you the data you want in the first instance.
In Excel select the Insert tab and select Pivot Table.
Set the table range to be A1 to C60000 (or whatever the max number of rows is)
Select New Worksheet and click OK.
Add the Name and Qt fields to the report. It should automatically sum Qt.
Add Date to the Filters. This should add a bar above the pivot table that says something like:
Date (All)
Click on (All) and select (blank), and that should exclude the rows with dates specified.
use helper cells next to the date range =isblank(d2) this will return TRUE in E2
put AAA in G6, in H6 put the following formula =SUMIFS(C:C,E:E,"TRUE",B:B,G6)
if there is trash data in the blank cells like random spaces and whatnot use =isblank(trim(d2))
i loooove pivot tables but sometimes they just make file sizes too big if using a bunch of them in a single workbook, i also get tired of refreshing them.

Resources