Such a method for getting a subtotal from related records is "display only" you can't access that value in a calculation or script step.
But there are other ways that you can use to compute the same subtotal that do not have this limitation.
You have not posted the filter expression that your are using, but most can be replaced by using additional match fields so that the filtering happens at the relationship level.
If you are using FileMaker 12 or newer, you can compute the same total with ExecuteSQL().
And a script could pull up the same set of records on a layout based on the portal's table and access this total from the summary field on that layout.
Thanks for the help.
Actually I am filtering and counting activities like activity x, activity y etc from other table.
I have got this command from http://help.filemaker.com/app/answers/detail/a_id/3423/~/counting-the-number-of-unique-values-in-a-field
ExecuteSQL ("SELECT COUNT (DISTINCT LocationField) FROM ContactTable" ; "" ; "")
But I couldn't got how to find specific value. For example how to find - how many times 'activity x' is there from ExecuteSQL?
Can you please describe or give a link for the same?