Jump to content
Sign in to follow this  
iain42

building a report layout calc field?

Recommended Posts

I have this report layout built for one of the Doctor's I work for but I am stuck.

Most of the report fields are averages but for margin% field he wants a percentage from margin field. The margin field data is either a 0 or a 1. I thought this would be simple enough.

I want a total of all the records in the database.

Then add up all the 1's in the margin field.

Divide the record count by total of 1's in the margin field to populate the margin% field.

This sounds simple but I rarely have to do a calc of this nature and it is making me crazy. Am I making this harder than it should be?

Any advice appreciated. I am still trudging through the fmpro help files.

Share this post


Link to post
Share on other sites

The margin field data is either a 0 or a 1.

I want a total of all the records in the database.

Then add up all the 1's in the margin field.

Divide the record count by total of 1's in the margin field to populate the margin% field.

Lets assume your Table is called "Data" for the sake of this example.

Create a calc field called "Rec1" that just contains a 1.

In the relationships graph duplicate your Data TO and call the second TO "Data Self"

create a relationship from one TO to the other using the Rec1 field.

Now create a calculation field called "MarginPrcnt" containing:

get(totalrecordcount) / sum(Data Self::Margin)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Who Viewed the Topic

    1 member has viewed this topic:
    vwgtiturbo 
×
×
  • Create New...

Important Information

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