Jump to content

Display subsummary data


This topic is 6234 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Hello,

I have a simple subsummary report in my database and am having trouble displaying the subsummary data on a web page using CDML.

My report consists of a subsummary part with two fields in it:

1) subject

2) subject count (a summary count of subject)

In the FileMaker database I get a result like:

Biology 5

History 10

Science 2

etc.

I don't know how to replicate this on the web.

I've tried sorting by subject and displaying the two fields within [FMP-Record] tags, but, of course, the subject field is repeated for every record in the found set and the subject count field gives only a count of all found records.

I can't hard code a separate find for each subject because there are many subjects and they can change at any time.

I know I could use a value list to display a list of the subjects, but I can't figure out how to get the subject counts to display.

I would appreciate any help.

Thanks!

Link to comment
Share on other sites

You can use either Javascript or Portals to achieve this.

Here is a method using [FMP-InlineActions] and Javascript:

Summaries

Here is a Javascript method that summarises a SORTED list:

<script>var tot_qty = 0; var loc_total = 0; var curr_loc = "Location";

[FMP-Record]

if (curr_loc == "[FMP-Field:location_name]")

	{

	loc_total += [FMP-Field:qty];

       tot_qty += [FMP-Field:qty]; }

else

    {

    document.write(curr_loc + " " + loc_total + "<br>");

    curr_loc = "[FMP-Field:location_name]";

    loc_total = [FMP-Field:qty];

    tot_qty += [FMP-Field:qty];

    } ;     	

[/FMP-Record]

document.write(curr_loc + " " + loc_total + "<br>");

document.write("Total Quantity: " + tot_qty);</script>

Hope this helps.

Garry

Link to comment
Share on other sites

I've tried to implement the solution, but I must be doing it wrong.

I put this code on body of the page on which I wish to display the results:

<script>var tot_qty = 0; var loc_total = 0; var curr_loc = "Location";

[FMP-Record]

if (curr_loc == "[FMP-Field:location_name]")

{

loc_total += [FMP-Field:subject_count];

tot_qty += [FMP-Field:subject_count]; }

else

{

document.write(curr_loc + " " + loc_total + "<br>");

curr_loc = "[FMP-Field:location_name]";

loc_total = [FMP-Field:subject_count];

tot_qty += [FMP-Field:subject_count];

} ;

[/FMP-Record]

document.write(curr_loc + " " + loc_total + "<br>");

document.write("Total Quantity: " + tot_qty);</script>

I get to that page using a link that finds all records with something in the subject field.

I don't see anything on my results page after I click the link.

Should I be putting in a value for "Location" or "location_name"?

I know you said this solution was involved both java script and inline action. I am new to inline action and am not sure how to implement that part. Could you tell me what I am doing wrong?

Thank you very much!

Lisa

Link to comment
Share on other sites

Lisa,

"Location" may be "subject" in your case. It is the field that is being sorted (with: &-sortfield=subject&) and the summaries are based on. Use the field name appropriate to your database.

Instead of [FMP:subject_count] you may just want to increment a counter, depends on your database. For example;

<script>var total = 0; var subj_total = 0; var curr_subj = "Subject";

[FMP-Record]

if (curr_subj == "[FMP-Field:subject]")

{ 

subj_total += 1; 

total += 1; }

else 

{ 

document.write(curr_subj + " " + subj_total + "<br>"); 

curr_subj = "[FMP-Field:subject]"; 

subj_total = 1; 

total += 1; 

} ; 

[/FMP-Record]

document.write(curr_subj + " " + subj_total + "<br>");

document.write("Total: " + total);</script>

Good Luck.

Garry

Link to comment
Share on other sites

  • 9 months later...

Thanks Garry, I used your javascript code too. Very helpful as I find both javascript and getting summary fields displayed within FMP rather tricky.

Couple of probs I ran into that may help others...

Put '&-max=all' in your calling url or only the first 25 records seem to get processed.

If the sort field name has a space in it use '+' not '%20' in the url.

Don't put any html comments after <script> to hide for non-supporting browsers, it seems to break it for some reason.

Link to comment
Share on other sites

This topic is 6234 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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.