jaboda Posted August 14, 2019 Posted August 14, 2019 I was looking for an easy way to get a record count of a portal and couldn't see how to do it anywhere. Luckily I found a workaround to do it and thought I'd share. Select Insert | Other Symbol. Select FoundCount. Move the new merge field into a portal row. Hide the merge field by setting 'Hide object when' to True. Give the merge field a name, for example 'PortalCount'. Now you can use the following calculation to find the total row count for the portal: GetLayoutObjectAttribute ( "PortalCount" ; "content" ) Obviously you can change 'PortalCount' to whatever you like. If there's an easier (and less hacky) way to do this please let me know.
comment Posted August 14, 2019 Posted August 14, 2019 (edited) Is your portal filtered? If not, the problem becomes "how to count related records" and can be solved by a calculation field in the parent table = Count ( ChildTable::Matchfield ) or by defining a summary field in the child table and placing it on the layout of parent. If the portal is filtered, you can place the summary field in a one-row portal that is filtered using the same filtering expression. Only if the portal is filtered AND you need to use the count of shown records in a further calculation, you would need to use the GetLayoutObjectAttribute() function. But in such case it might be more appropriate to filter the relationship rather than the portal - IOW, work purely at the data level. Edited August 14, 2019 by comment
jaboda Posted August 20, 2019 Author Posted August 20, 2019 Yes the portal is filtered. Using GetLayoutObjectAttribute() allows me to not put a summary field in the table structure so I think is cleaner.
comment Posted August 20, 2019 Posted August 20, 2019 As I tried to say earlier, the cleaner solution is not to rely on layout objects for calculations at the data level.
jaboda Posted August 20, 2019 Author Posted August 20, 2019 I get your point but your suggestion would require a second Portal and an entry in the table structure. My technique only requires an additional field in the existing portal... Unfortunately FileMaker doesn't support Queries, which would be the neatest solution.
comment Posted August 20, 2019 Posted August 20, 2019 20 minutes ago, jaboda said: your suggestion would require a second Portal and an entry in the table structure. I made several suggestions. You need a second portal only if you want to display the filtered count (and display it only once). If you need it for further calculations, you should not be using a portal to get it. 25 minutes ago, jaboda said: Unfortunately FileMaker doesn't support Queries Not sure what you mean by "Queries". Filemaker certainly does support (a subset of) SQL queries. Whether that would be "the neatest solution" depends on the situation; replicating an existing relationship using SQL is not very appealing.
jaboda Posted August 20, 2019 Author Posted August 20, 2019 2 minutes ago, comment said: Not sure what you mean by "Queries". Filemaker certainly does support (a subset of) SQL queries. Whether that would be "the neatest solution" depends on the situation; replicating an existing relationship using SQL is not very appealing. I'm referring to Queries (such as in MS Access) or Views (in MySQL) which provide a layer between the table structure and the forms/reports. FileMaker puts the equivalent in the table structure. In my experience FileMaker's implementation of SQL is extremely slow and only useful for certain applications. In this case it's much better to use FileMaker relationships.
Recommended Posts
This topic is 1978 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now