Jump to content

Calculate median across record range


Recommended Posts

Hi, in the attached database, we collect a range of readings per date. I need to calculate the median for each element (eg temperature, pH etc) across a range of dates. There is one record per date.

The user will change the range of dates depending on what time period they want to view. The data doesn't need to be summarised by anything.

I am most of the way there, thanks to this great post: https://www.briandunning.com/cf/298. I have run the script in that link on a field doing a summary list. However, the list doesn't seem to sort as specified in the script, and the median value returned is not always accurate.

The lab results layout has been temporarily set up so I can see the summary field for each element below the median calculation field, with the actual data in the body. This way I could see what the sort was etc. I've just put in 5 records to test this, and to test what happens when there are odd and even records. sign in is admin/admin.

Grateful for any help!

H

 

 

Edited by Hurlz
...
Link to post
Share on other sites

A simplified demo file showing only the problem would have been appreciated. AFAICT, the problem is that you're sorting the values incorrectly as text, instead of as numbers. 

 

Link to post
Share on other sites

thank you for that. I thought I had changed that for all calculations but had not. My apologies and sorry for not sending a simpler file too.

Link to post
Share on other sites

Good.

BTW, I think you could make your calculation more elegant by using GetValue() instead of MiddleValues() and Div() instead of Truncate().  And I would also use ValueCount() to count values, instead of WordCount().

 

Link to post
Share on other sites

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
  • Similar Content

    • By dancer5678
      I am using Filemaker Server 18 on Windows Server 2012 R2
      Been using it for years with no issues
      Currently when I log in to the console it is very sluggish.
      When I get to the Dashboard it shows No databases, then it auto refreshes and the database list appears.
      Within 15 seconds of scrolling the database list to open files the screen refreshes. This situations is happening over and over in a loop.
      Any Thoughts on what is causing this issue?
       
       
       
       
    • By stevaroni
      I get an error 3 when using a script to Export Records via WebDirect. Using FileMaker Server 18 and have tried both Safari and Chrome both with same results. I have tried using the temporary path, desktop path, and documents path. I have tried using with the automatically open and not. I have tried writing a tab delimited and comma delimited file. Does anyone have ideas I haven't yet tried?
    • By cheerfulzebra
      Hi All
       
      I am hoping some one can help!
      I have a table called TPM, in that table is a field "Next Due Date" Which is auto generated by creating a new record. You input the date you did the service and then it adds 3 months to that date and that appears in the Next Due Date Field.. All working...
       
      What I am trying to do is when the database loads it runs a script to see if there are any outstanding TPM Services to do...
      Here is the script
      Show Customer Dialog
      Message: If ( TPM::TPM Next Due Date < Get (CurrentDate ) ; "You have outstanding TPM services" ; "You have no outstanding services")
      I thought it would be that simple. So I created a TPM Due date Less that Current date and ran the script...."You have outstanding TPM Services"...GREAT! Then I deleted that record and ran the script again...""You have outstanding TPM Services" Oh!!! That isnt true!
       
      PLEASE HELP I'M LOOSING THE WILL TO LIVE HERE!!!
    • By Kitesurfer
      Hi,
      Can someone please explain why Leftwords function is not properly working when importing an excell sheet.
      For example the name John Doe LeftWords ( Client ; 1 ) should show "John" only.
      When typing John Doe it works fine but not when importing ????
      Looking forward to a reply.
      Kind regards
      Rudy
    • By Pio Soto
      Hi,
      My issue is that my customer layout has a script trigger on LayOutEnter that sorts my customers portal list by "Active" customers,
      but when I do a go to related record from another table say from quotes or any other the customer layout does not load that customer
      or show my related customer because the OnLayoutEnter script trigger changes it, I would like it to go to the related customer and also sort it by "Active"
      on the list.
      Hope someone can help me with this.
      Thanks,
      Pio

×
×
  • Create New...

Important Information

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