HI BB,
The only use made of IF in Quinn's solution, or in mine, is to create the index column used to determine which rows will provide the list of city names for List 2. INDEX, or one of the LOOKUP functions is used to transfer the data to List 2.
IF can be used (as it is in List 2 - 1 below) to determine if there is a need to transfer data in each row.
Formulas
List 1:
Columns A, B and C contain entered data.
D2: =IF(COUNTIF($A$2:A2,A)=1,MAX($D$1:D1)+1,"")
This is the same formula as used in my earlier post. The range for MAX is now in column D to match the new position of the index column. I prefer to have these in the last column of the table (and hidden) to get them out of the 'danger zone' where data is being entered.
IF is used here to tell the formula to add 1 to the MAX value only on the row where a city name first appears.
List 2-1
A2: =IF(ROW()-1>MAX(List 1 :: $D),"",INDEX(List 1::A,MATCH(ROW()-1,List 1::$D,0)))
Same formula as in previous example, with the index reference changed to column D to match the new location, and made absolute ($) to keep it there as the formula is filled or copied into column C.
The formula in A2 was filled right to B2 (temporarily) and C2
C2: =IF(ROW()-1>MAX(List 1 :: $D),"",INDEX(List 1::C,MATCH(ROW()-1,List 1::$D,0)))
The only change from the version in column A is the part shown in bold, which tells Numbers to get the (currency) values from column C of List 1.
B2: The filled right formula from column A would retrieve only the first order value from each city. As we want the total, it must be changes to a SUMIF formula.
As in the other formulas, the working core will be enclosed in an IF statement to suppress calculations where they are not needed. The test is for an entry in the City column.
B2: =IF(LEN(A)>0,SUMIF(List 1 :: A,A2,List 1 :: B),"")
Select cells A2, B2 and C2 on List 2-1, and Fill down to the end of the columns.
Regards,
Barry