Good question, Ken. You have a few options...
Using Rows won't work directly as those relationships are predicated upon you setting the IDs of all the records you're interested in into the globals in the Selector. In your case the would mean the IDs of all the unpaid invoices YTD--you'd have to find them and then get all their IDs...but if you've gone to the trouble of finding them then using Selector gets kind of redundant. =) The Selector isn't the most efficient way to do this kind of reporting. I can suggest two approaches:
SQLAt first glance, this is what SQL was made for: you want to aggregate data from a bunch of tables (invoices, clients, projects) from a context that isn't really bound to any one of them: the dashboard or Home layout. SQL lets you make these kind of queries out of context (regardless of what layout you're on) AND includes functions to sum or count the results in one step. So you could write single line of SQL that would get you the sum of the unpaid invoices YTD and could even put that *right in* an unstored calc in the Home table. (If you need help writing SQL calcs like this I strongly recommend SQLexplorer; makes this kind of thing MUCH easier:
http://www.seedcode.com/filemaker-sql-explorer/ )
But...
Since you want to write over ten of these aggregate functions, you're talking about asking FileMaker to do a lot of work. And if these are just unstirred calcs in Home then you'll do that work *every* time you arrive at the Home layout. That brings up the first suggestion I'd make: however you end up calculating these stats, have a script set them into *global fields* on demand instead of using live fields. This way you can set them when the user first opens the solution (if you want) and the values will just hang out in those globals as the user returns to home over and over, never asking your solution to do any more heavy lifting until the user runs your script to refresh the dashboard. That may not sound as fun as "live" calcs, but this is how you keep this thing from ruining the performance of your solution. =)
The second suggestion I'd make is not to use SQL unless you're using FileMaker Sever. The reason is that each of these SQL calls will need to pull the whole index of each relevant table from the server to the client in order to complete the query. As you get more invoices, clients, and projects your users will really start to feel that. If you have server you can run these queries in a script using Perform Script on Server (PSOS) and then only bring the *results* back to the client across the wire. (For a great example of how PSOS can speed up this kind of thing, check this out:
http://www.seedcode.com/chasing-filemak ... rformance/ )
Perhaps a better idea is not to use SQL at all...
RelationshipsThe other approach is to build dedicated relationships for these dashboard queries. That means you'd have a table occurrence hanging off Home called "DashboardInvoicesPaid" and this relationship would only show Paid invoices for the user selected Date Range (once you're going to the trouble of this, why not make your date ranges global fields in home so you can report these values YTD, or LastYearTD, or any other range you need?) Then you'd have a script that set your global dashboard value to the sum of those invoices, something like Sum ( DashboardInvoicesPaid::TotalGrand ), and other line in the same script would set the total number of those invoices in your dashboard to Count ( DashboardInvoicesPaid::id )
This is the same idea as I mentioned above, where you don't show live calcs but use a script to refresh the dashboard as needed.
Aside from being "simpler" (unless you're a SQL wiz), this relationship approach has one other big advantage over SQL: once you have a relationship to Paid Invoices you can use the GoToRelatedRecord script step to go see those Paid Invoices YTD. This makes it version easy to but a view button on your dashboard to jump to a found set of relevant invoices. That would be a whole separate scripts if you were doing SQL reporting AND since the script wouldn't use exactly the same code as the SQL query to find the records, you could accidentally use slightly different criteria in your aggregates as in your finds: that gets confusing very quickly.
So while relationships aren't as - as doing this with SQL, I think you get more bang for your buck. And you can still run your "refresh dashboard" script using PSOS if you want to.
Let me know if making a relationship like I described for DashboardInvoicesPaid is new to you and I'll post an example.
- John