Jump to content

Counting Distinct Values for a Chart


Greg Hains

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

Recommended Posts

Good morning.

I am having trouble displaying data in a chart - this may be as much about schema and relationships as it is about charts, but here goes...

I have a table called "SOAP Notes". This table has about 12,000 records. In this table, two of the fields are Date (a date field - surprise!) and Date_Count field - a calculation field that reads this:
ExecuteSQL ("SELECT Count ( \"Date\" ) FROM \"SOAP Notes\" WHERE \"Date\" >= ? AND \"Date\" <= ?" ; ""; ""; Date; Date)

This calculation field gives me a count of any given day - works fine.
I then narrow down the data to be displayed with a FIND (for example "9/2018" in the Date field), I still get repeats of the same date, so there might be 10 items in the chart that are for 1/9/2018 when I really only want to show 1 entry per day - a total of 30 for the month of September.

I cannot work out how to apply the DISTINCT option to the above statement.
It may be "lazy" but I feel I can achieve this result without creating a plethora of relationships to other tables and only modifying this statement a little.

Could somebody please throw me a clue?
Thank you in advance.
Greg

Link to comment
Share on other sites

I am somewhat confused by your description- and especially by the title. If I understand this correctly, you do NOT want to count distinct values; you want to display (only) distinct values along the X axis, and show their count within the current found set as the Y axis values - is that correct?

If so, I suggest this would be much simpler to accomplish using Filemaker native methods: define the chart to use the Date field as the X axis labels and a summary field defined as Count of [any field that cannot be empty] as the Y axis data. Set the chart to use data from the current found set, and select the Summarized groups of records option for Chart display when layout is sorted.

Before displaying the chart,  find the relevant records and sort them by the Date field.

Link to comment
Share on other sites

Hi Comment,

Thank you once again for coming to my rescue. :)
Yes, my description could have been better, but you knew what I meant.

I did have all the settings correct as you described, but I did not sort the records again. Once they were sorted, everything came good.

Cheers,
Greg

 

Link to comment
Share on other sites

This topic is 2017 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
×
×
  • Create New...

Important Information

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