Frage

I have two sheets, connected by ID, which contain details of events and charges.

Sheet1 (breakdown of charges): [Oh, just discovered I'm not allowed to include screen shots. I apparently need 10 reputation points. Not sure how to show you my spreadsheet now...]

ID   DBF    PCC    Extras
 1                 200
 1         100  
 3   200
 4   350        
 4         250  
 4               75
 4               25
 7   100        

[Sorry this will probably look horrible, I can't figure out how to include a spreadseet snippet without using an image. I had 3 imaage all prepared ready.]

Sheet2 (indentification and summary information):

ID  Type    Name
3   MON Edwards
7   REC Smith
4   WDG Jones
1   FNL West
8   WDG Richards
9   WDG Morrison
11  INT Gray

I am trying to add three additional columns to sheet 2 so that it shows a summary of the charges for each event. I would the charges information to update automatically in sheet2 as detail is added to sheet 1.

The resulting sheet2 will look like this:

ID  Type    Name    DBF PCC Extras
3   MON Edwards 200     
7   REC Smith   100     
4   WDG Jones   350 250 100
1   FNL West        100 200
8   WDG Richards            
9   WDG Morrison            
11  INT Gray            

As data for ID 8, 9 and 11 is added to sheet1, the summations should automatically appear in sheet2.

I have been trying to create an array formula to put in sheet2:B2, something like this:

 =QUERY('Log Items'!A:F, "select sum(C), sum(D), sum(E), sum(F) where A="&A:A, 0)

This produces the correct result for ID 1 but it stops there and I'm not sure why. Also, despite my 0 as the third parameter, the header row is output.

I tried encapsulating the above in an ARRAYFORMULA but get a parse error.

I have also tried various combinations of ARRAYFORMULA, SUM and IF but not got anything that works. For example:

=ARRAYFORMULA(SUM(IF('Log Items'!A:A=A:A,'Log Items'!C:E,0)))

This gives #N/A "argument out of range", which I don't understand.

Although I've been working with Excel for a while, I'm really new to Google's Array formulas but have mananged to use them successfully in other parts of my spreadsheet and found them really powerful.

If anyone could help me with this, I would be very grateful.

War es hilfreich?

Lösung

In Sheet2!D2:

=ARRAYFORMULA(IF(A2:A,MMULT(N(A2:A=TRANSPOSE('Log Items'!A2:A)),N('Log Items'!B2:D)),))

Note: the N() functions have become necessary with different coercion behaviour in the new version of Sheets. They can be omitted in the classic version.

MMULT usage

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top