Thanks Aladin for your help so far - i've worked through and this is what I have...
Good job.
All seems to work ok except occasionally there is an entry with a fee of 0 (the reasons for this don't really matter), just it returns an #N/A error in the client name - what amendments do i need to make to handle any clients with a fee of 0 against them?
I did not expect a 0 fee. Its presence forces us to contain the othwerwise absolutely correct behavior of the frequency function. Here IFERROR comes to rescue.
The formula seems to work for any given month but if I put in 01/09/16 and 31/08/17 (our FY) I get what seems like a random amount back (e.g. it calculates the 1st four then misses one out completely - Will it only work for a month date range?
I should have not have confined the set up to a month date range. No worry. It's easy to resolve.
In what follows I'll use named ranges to make the formulas more readable.
Happy to send you across the sheet if it helps but i'll need to PM it as there is sensitive info within it.
Thanks. I don't think that's necessary.
[Table="width:, class:grid"][tr][td]Row\Col[/td][td]A
[/td][td]B
[/td][td]C
[/td][/tr][tr][td]1
[/td][td]client[/td][td]date[/td][td]fee[/td][/tr]
[tr][td]2
[/td][td]john[/td][td]8/1/2016
[/td][td]0
[/td][/tr]
[tr][td]3
[/td][td]dave[/td][td]8/5/2016
[/td][td]600
[/td][/tr]
[tr][td]4
[/td][td]fred[/td][td]8/8/2016
[/td][td]750
[/td][/tr]
[tr][td]5
[/td][td]dave[/td][td]8/14/2016
[/td][td]250
[/td][/tr]
[tr][td]6
[/td][td]steve[/td][td]9/1/2016
[/td][td]400
[/td][/tr]
[tr][td]7
[/td][td]steve[/td][td]9/2/2016
[/td][td]50
[/td][/tr]
[tr][td]8
[/td][td]colin[/td][td]10/3/2016
[/td][td]300
[/td][/tr]
[tr][td]9
[/td][td][/td][td][/td][td][/td][/tr]
[tr][td]10
[/td][td][/td][td][/td][td][/td][/tr]
[tr][td]11
[/td][td][/td][td][/td][td][/td][/tr]
[tr][td]12
[/td][td][/td][td][/td][td][/td][/tr]
[tr][td]13
[/td][td][/td][td][/td][td][/td][/tr]
[tr][td]14
[/td][td][/td][td][/td][td][/td][/tr]
[tr][td]15
[/td][td][/td][td][/td][td][/td][/tr]
[tr][td]16
[/td][td][/td][td][/td][td][/td][/tr]
[tr][td]17
[/td][td][/td][td][/td][td][/td][/tr]
[tr][td]18
[/td][td][/td][td][/td][td][/td][/tr]
[tr][td]19
[/td][td][/td][td][/td][td][/td][/tr]
[tr][td]20
[/td][td][/td][td][/td][td][/td][/tr]
[/table]
The data is assume to be located in A:C of Sheet1 (Adjust to suit.).
2. Define
Client as referring to Sheet1!$A$2:$A$20 in Name Manager.
3. Define
Date as referring to Sheet1!$B$2:$B$20 in Name Manager.
4. Define
Fee as referring to Sheet1!$C$2:$C$20 in Name Manager.
5. Define
Ivec in Name Manager as referring to:
=ROW(Client)-ROW(INDEX(Client,1,1))+1
Sheet2 (where we do the processing)
[Table="width:, class:grid"][tr][td]Row\Col[/td][td]A
[/td][td]B
[/td][/tr][tr][td]1
[/td][td]start[/td][td]end[/td][/tr]
[tr][td]2
[/td][td]8/1/2016
[/td][td]8/31/2016
[/td][/tr]
[tr][td]3
[/td][td]3
[/td][td][/td][/tr]
[tr][td]4
[/td][td]client[/td][td]fee[/td][/tr]
[tr][td]5
[/td][td]dave[/td][td]850
[/td][/tr]
[tr][td]6
[/td][td]fred[/td][td]750
[/td][/tr]
[tr][td]7
[/td][td]john[/td][td]0
[/td][/tr]
[tr][td]8
[/td][td][/td][td][/td][/tr]
[/table]
In A3 control+shift+enter, not just enter:
=SUM(IF(FREQUENCY(IF(1-(Client=""),IF(ISNUMBER(Date),IF(Date>=A2,IF(Date<=B2,MATCH(Client,Client,0))))),Ivec),1))
In A5 control+shift+enter, not just enter, and copy down:
=IF($B5="","",INDEX(Client,SMALL(IFERROR(IF(SUMIFS(Fee,Client,IF(FREQUENCY(IF(1-(Client=""),IF(ISNUMBER(Date),IF(Date>=$A$2,IF(Date<=$B$2,MATCH(Client,Client,0))))),Ivec),Client),Date,">="&$A$2,Date,"<="&$B$2)=$B5,Ivec),0),COUNTIFS($B$5:B5,B5))))
In B5 control+shift+enter, not just enter, and copy down:
=IF(ROWS($B$5:B5)>$A$3,"",LARGE(SUMIFS(Fee,Client,IF(FREQUENCY(IF(1-(Client=""),IF(ISNUMBER(Date),IF(Date>=$A$2,IF(Date<=$B$2,MATCH(Client,Client,0))))),Ivec),Client),Date,">="&$A$2,Date,"<="&$B$2),ROWS($B$5:B5)))