Compare cell in excel - excel

i have some data like below in one column.
Value
-----
A#show
20
20
B#show
20
25
30
C#show
10
10
10
10
D#show
10
E#show
10
20
I want to compare the values between the cell where the last string is "show" and if there is only one then no comparison.
Value Comparison
----------------------
A#show Same
20
20
B#show different
20
25
30
C#show same
10
10
10
10
D#show only one
10
E#show different
10
20
I think it's can be possible using a VBA script

It's a bit unclear what you're trying to compare between values. However, there is a way to do this without VBA.
1) In the Second Column, create a "Header" column which names which header each value belongs to. The first entry would just be A#show, but then the following would be:
=IFERROR(IF(A2*1>0,B1),B2)
2) In the third column, you can utilize countif to see if the header has more than 2 entries (indicating it has a comparison). Here is where you can apply whatever comparative metric you'd like. If it's something unformulaic, just use a pivot table with the 3 columns.

Related

Sumif of multiple Index matches against one value

Need help regarding Excel dynamically search based sum of two columns matching from two different tables.
I have got this Table of Data Entered One Time
A B C
1 Qlty Warp Weft
2 Stpl.1 150 20
3 Cotn.1 80 60
4 Stpl.2 20 20
5 Cotn.2 20 20
6 Stpl.3 20 40
in Column A2:A6, Quality can not be duplicated, its a unique Name
The Data entry and report Table is here
A B C D E F
8 Yarn Name Sent Bags Remaining Qualty Used Warp Used Weft
9 20 800 600 Stpl.1 71 200
10 150 101 30 Stpl.2 70 30
11 40 300 290 Stpl.3 100 10
12 20 400
C9:C5000 is Returning Column, Values are calculated on the base of Column A9:A5000 (Yarn Name)
Need to Find Yarn Name (eg:) "20" in B2:B6 AND/OR C2:C6, wherever it matches, index that Quality from A2:A6
Then match the returned qualities(could be more than one) to D9:D5000 and sum the mathced results from E9:F5000
I have tried so far in C12
=SUMIF($A$9:$A12,A12,$B$9:$B12)-(SUMIF($D$9:$D12,INDEX($A$2:$A$6,MATCH(A12,$B$2:$B$6,0)),$D$9:$D12)+SUMIF($D$9:$D12,INDEX($A$2:$A$6,MATCH(A12,$C$2:$C$6,0)),$D$9:$D12))
PS:- I am using Excel 2007
If I understand correctly, then following array formula can help you:
=SUM(IFERROR(INDEX($A$2:$A$6,N(IF(1,(MMULT(--($B$2:$C$6=A9),TRANSPOSE(COLUMN($B$2:$C$6)^0))>0)*(ROW($B$2:$C$6))-1)))=TRANSPOSE($D$9:$D$12),0)*TRANSPOSE($E$9:$E$12+$F$9:$F$12))
Array formula after editing is confirmed by pressing ctrl + shift + enter
Edit:
To calculate Warp and Weft columns separately use following array formula:
=SUM(IFERROR(INDEX($A$2:$A$6,N(IF(1,((A9=$B$2:$B$6)*ROW($B$2:$B$6))-1)))=TRANSPOSE($D$9:$D$12),0)*TRANSPOSE($E$9:$E$12))+SUM(IFERROR(INDEX($A$2:$A$6,N(IF(1,((A9=$C$2:$C$6)*ROW($C$2:$C$6))-1)))=TRANSPOSE($D$9:$D$12),0)*TRANSPOSE($F$9:$F$12))

Compare two different tables with same rows but not exactly in the same order in Excel

I want to compare two different tables in Excel if they have exactly the same rows [number of rows and their fields] but the rows may not be necessarilly in the same order,
say:
col1---col2---col3---col4 col1---col2---col3---col4
1 10 15 2 3 30 13 6
2 20 14 4 4 40 12 8
3 30 13 6 1 10 15 2
4 40 12 8 2 20 14 4
TABLE_1 TABLE_2
I call this equivalent tables.
Is there an excel function, or combination of functions, that can give me TRUE if both tables are equivalent, and FALSE if not?
You can put two helper columns in the tables with the following formula:
=SUMPRODUCT(--(A2:D2=INDEX(G:J,MATCH(A2,G:G,0),0)))=COLUMNS(A:D)
and
=SUMPRODUCT(--(G2:J2=INDEX(A:D,MATCH(G2,A:A,0),0)))=COLUMNS(G:J)
Then count those helper columns for FALSE:
=AND(COUNTIF(E:E,FALSE)=0,COUNTIF(K:K,FALSE)=0)
This will return FALSE if any of the rows return false.
And when one cell does not match:
You may go around it with the following shortcut, which is not 100% sure but very high possibility of being sure. but it is extremely easy to apply.
first, format your tables as real Tables. Home enu>Format as Table
then, write this formula: =SUM(Table1)=SUM(Table2)
it would be very little probability for them to be equal if they are not the same.

Referencing the previous row in Spotfire and a value in another column

I'm trying to do something that is very simple to do in Excel, but seems very tricky in Spotfire:
Imagine you have the following table:
A
1: 10
2: 15
3: 20
... and you want to produce the following:
A B
1: 10 10
2: 15 25
3: 20 45
In other words, add the current value of A to the previous value of B. If this was Excel, the formula in cell B3 would be = A3 + B2... However, I'm not in Excel, I'm using Spotfire... :) Any thoughts?
NB: If it makes any difference to the answer at all, I will need to use the Intersect() function in conjunction with this, as there is a categorical column to factor in as well.
Hope this helps, I have considered the first column as ID
ID A B
1 10 10
2 15 25
3 20 45
If(Sum([A]) over (AllPrevious([ID])) is null,sum([A]) over ([ID]),Sum([A]) over (AllPrevious([ID])))

Create a formula that returns a minimum date from a range based on cell values in another column

I am looking for a formula that will return the earliest date from a column, based on the contents of values in other cells. (Actually I want a Min and Max date, but am assuming the Max will be identical to any Min solution )I know I can return the date I want just by using MIN and specifying the range of cells I want, but I ideally want the formula to be dynamic. I have looked around and believe I possibly need to use a combination of index and match, but cant find any examples that use Min and Max. I have considered using dynamic named ranges to define my task groups, but that would mean having to define a static number of task groups, and there could be many task groups.
The sheet below shos some sample date on the left of the workbook, with the summary data on the right. The "hidden worker column" was an idea I had that I though might make the solution easier. So I want the summary data on the right to use either column A, or column B if its easier, to display the min and max dates based on the section number in column F - Is this possible without VBA?
#mthierer's link is good. If you wanted to remove the need to add a "helper column", you could try (data in A1:C10; summary table in E1:G2):
{=MIN(IF(ROUNDDOWN($A$1:$A$10, 0)=$E1, $B$1:$B$10))} (or {=MAX(...)} with $C$1:$C$10)
Note that you have to enter the formula as an array formula with CtrlShiftEnter.
Data (A1:C10):
1 23 57
1.1 42 91
1.2 35 100
1.3 39 80
1.4 28 51
1.5 30 96
2 33 52
2.1 11 73
2.2 48 80
2.3 16 59
Summary Results (E1:G2):
1 23 100
2 11 80

Find duplicates and count numbers at the same time

I have rows of data that contains numbers from 1 to 15, however these numbers can be in any sequence. For example here:
3 2 1 12 13 5 6 7 9 15 10 8 4 15 11
I know from a visual count these numbers above are all correct; as there are no duplicates, and all the numbers have values from 1 to 15. An example of a row of data I found to be wrong:
3 2 1 12 12 5 6 7 9 15 10 8 4 15
You can see this line has duplicated numbers i.e. 12, and number 11 is missing, so this row only has 14 elements in all.
However, I have many rows of data and it is impossible to visually check each row. I need to ensure in each row: there are 15 elements; there are no duplicates, and that the row contains values from 1 to 15 and find which rows are faulty to check these against the original paper data.
Is there a command or function that I can use in Excel to make this process easier?
You could find a set of conditions, each of which is true for rows that contain exactly those 15 numbers in any order and then test several of them. For example, if the row is in A5:O5:
=AND(COUNT(A5:O5)=15,SUM(A5:O5)=120,MIN(A5:O5)=1,MAX(A5:O5)=15,
AVERAGE(A5:O5)=8,ROUND(STDEV(A5:O5),3)=4.472)
This will show TRUE for a row that contains the integers 1 to 15 in any order, and is very unlikely (it could very well be impossible - I haven't checked) to show TRUE for a row that contains any different set of integers.
I'm pretty sure that the only way 15 positive integers less than 16 can add up to 120 other than by all being different is with duplication, so :
Check there are 15 numbers
Check their total is 120
Check the maximum is 15
Check not negative (nor zero):
=IF(OR(COUNT(A5:O5)<>15,SUM(A5:O5)<>120,MAX(A5:O5)>15,MIN(A5:O5)<1),"Error","Plausible")
then check for duplication with Conditional Formatting using a rule such as :
=COUNTIF($A5:$O5,A5)>1
and a distinctive format. Filter to select "Plausible" and then anything with a distnctive format is non compliant.

Resources