mercredi 10 avril 2019

Calculate a value for 2 different set of IDs in excel

My excel table has 5 Rows: Id, ColA, ColB, Count and Test.

ID  A   B   Count  Test
2   a  low   5     -
2   b  high  6     -
2   c  low   7     - 
2   d  high  8     -
2   e  low   9     -
1   a  low   1    =(1-5)
1   l  high  2    -
1   e  low   3    =(3-9)

I want to Calculate the value of Test for only rows with Id = 1

If Value of ColA for ID 1 = Value of of ColA for ID 2 and 
   Value of ColB for ID 1 = Value of of ColB for ID 2
then calculate the difference between the Count Values 
else
0

The Excel Table is connected to Sql Query. Every time I refresh it the table has a different number of rows.

I tried using VLOOKUP in TEST column where Id = 1 and specified the array table as the first 5 rows (only with Id = 2) but it doesn't seem to work because when I refresh the table the second time there are only 2 rows for Id = 2.

I want the TEST column value to be automatically calculated each time the table is refreshed. Thanks!

Aucun commentaire:

Enregistrer un commentaire