Return unique column headers matching criteria - excel

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".

Related

Transform data in Excel (rows and columns)

Current input:
+-------------------------+
| col A |
+-------------------------+
| Test(read) |
| - ABC(dsakl) |
| - ABC(dslø) Write(T) |
| - ABC(dsjkl) |
| Test(true) |
| - ABC(DSdsa) |
| - ABC(dsalk**) write(F) |
+-------------------------+
Wanted output:
+-------------------------+-------------------------+
| col A | col B |
+-------------------------+-------------------------+
| Test(read) | - ABC(dsakl) |
| Test(read) | - ABC(dslø) Write(T) |
| Test(read) | - ABC(dsjkl) |
| Test(true) | - ABC(DSdsa) |
| Test(true) | - ABC(dsalk**) write(F) |
+-------------------------+-------------------------+
Hence, I want to transform my data so everytime "Test" occurs it creates a new row in column "A" corresponding to the number of rows until the next "Test" occurs. The cells containing "ABC" should be written in column "B" in the output file.
Really appreciate input on this one. Thanks!
There may be other approaches to this, but if you want to do it purely with regular formulas you could try this:
Do col B with Aggregate to find the first row with a "-", then the second etc.
=IFERROR(INDEX(A$1:A$10,AGGREGATE(15,6,ROW(A$1:A$10)/(LEFT(A$1:A$10)="-"),ROW())),"")
Col A is more difficult - this finds the nth row starting with "-" as before, then looks before this to find the last row starting with T:
=IFERROR(INDEX(A$1:A$10,AGGREGATE(14,6,ROW($A$1:INDEX(A$1:A$10,AGGREGATE(15,6,ROW(A$1:A$10)/(LEFT(A$1:A$10)="-"),ROW())))
/(LEFT($A$1:INDEX(A$1:A$10,AGGREGATE(15,6,ROW(A$1:A$10)/(LEFT(A$1:A$10)="-"),ROW())))="T"),1)),"")

excel - COUNTIF

I have a table with three columns. Column C contains the formulas. Right now, I'm putting in the formulas by hand. I need a modified version of the same formula that I can drag-down and uses the correct ranges.
| Column A | Column B | Column C
|-------------------------|---------------------|-----------------------------
| abiding_jj citizen_nn | (abiding1) | 1[=COUNTIF(B$1:B$1,B1)]
| (BLANK ROW) | |
| abrupt_jj end_nn | (abrupt2) | 2[=COUNTIF(B$3:B$7,B3)]
| abrupt_jj end_nn | (abrupt1) | 3[=COUNTIF(B$3:B$7,B4)]
| abrupt_jj end_nn | (abrupt1) | 3[=COUNTIF(B$3:B$7,B5)]
| abrupt_jj end_nn | (abrupt1) | 3[=COUNTIF(B$3:B$7,B6)]
| abrupt_jj end_nn | (abrupt2) | 2[=COUNTIF(B$3:B$7,B7)]
| (BLANK ROW) | |
| abrupt_jj halt_nn | (abrupt1) | 3[=COUNTIF(B$9:B$12,B9)]
| abrupt_jj halt_nn | (abrupt3) | 1[=COUNTIF(B$9:B$12,B10)]
| abrupt_jj halt_nn | (abrupt1) | 3[=COUNTIF(B$9:B$12,B11)]
| abrupt_jj halt_nn | (abrupt1) | 3[=COUNTIF(B$9:B$12,B12)]
If I understand correctly, you want to treat observations that are separated by a blank row as different "groups". This could be solved by adding an extra column that creates "group" numbers that you can then use in a countifs formula.
An example with the "groups" in column A:
Column A contains 1 in A1, to mark the first group, and a formula in subsequent rows: =IF(ISBLANK(B#),A#+1,A#) (as shown in the snapshot, with # being the previous row).
It's not very elegant but it seems to do what you want.

Excel function, exclude dates in chart data source

I am forming a chart from sheet A. Sheet B contains all my data.
I want to exclude a specified date(s).
Sample data:
+---+----------+--------------+--------------+-------------+-------------+-------------+
| | A | B | C | D | E | F |
+---+----------+--------------+--------------+-------------+-------------+-------------+
| 1 | Date | 29/03/2017 | 30/03/2017 | 31/03/2017 | 03/04/2017 | 04/04/2017 |
| 2 | Number 1 | -594590.4649 | -636666.4504 | 795637.1614 | 842563.4322 | 496463.9301 |
| 3 | Number 2 | 2189587.44 | 1301681.418 | 2080839.353 | 1945335.214 | 2421728.123 |
+---+----------+--------------+--------------+-------------+-------------+-------------+
The final output would be me excluding 30/03/2017 , and keeping the rest in my data selected for my chart.
the issue is that I want to maybe exclude a date in the middle of my selected range. But since this may be a hassle to input a long formula each time into my data selected. I would like to see if there is any formula/function to eliminate a specified date/column. Perhaps manually enter the column you want to exclude in a formula.
My current range is something like =Graph!$AB$5:$KA$7 But is there a function to exclude one of these columns?
I can manually select which dates with Ctrl but seems tedious.

Excel 2010 Calculating Production line quantities without long calculations

Program: Excel 2010
Requirements: Prefer no VBA (Macro free book)
I am creating a spreadsheet to calculate items required for components (parts). I have a list of the product, and under the number of specific parts. I have a calculation which tells me what the total parts are needed, but, is there a better way?
=($C$32*C34)+($D$32*D34)+($E$32*E34)+($F$32*F34)+($G$32*G34)+($H$32*H34)+($I$32*I34)+($J$32*J34)+($K$32*K34)
| A | B | C | D | E | F |
| Making: | | 2 | 2 | 2 | |
|---------------|-------|------------|-------------|-----------------|---------|
| Item -> | Total | Small raft | Rowing boat | Sm sailing boat | Corbita |
| | | | | | |
| Planks | 20 | 4 | 6 | | |
| Logs | 8 | 4 | | | |
| Nails - Large | 16 | 8 | | | |
| Oars | | | | | |
In the above, you can see that ($C$32*C34) = 8 & ($D$32*D34) = 12 => 12+8 = 20 (B34) (Planks Total)
Is there an easier way of doing this, or will my equation just keep getting bigger?
Thanks in advance.
As chris neilsen mentioned in his comment, you can use the SUMPRODUCT function in Excel. The formula in your cell B34 (total planks) should look like this:
=SUMPRODUCT(C32:K32,C34:K34)
This has the effect of multiplying the corresponding components in the given ranges (C32 * C34, D32 * D34, etc.) and then returning the sum of those products/multiplications.
As you add more columns, you can expand K to the last column in the range that you want to add up in both ranges.

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