dbTalk Databases Forums  

How to build an array with data from a single table?

comp.databases.filemaker comp.databases.filemaker


Discuss How to build an array with data from a single table? in the comp.databases.filemaker forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
lansingoogle
 
Posts: n/a

Default How to build an array with data from a single table? - 12-07-2011 , 04:59 PM






I have a client that wants an excel-style report composed of data from
a single table. In this case, the records contain "city" data and
creation dates, and they want a report that will have cities
populating the 'rows', and records-per-month populating the columns
(columns would be Jan, Feb, March, etc.). So... San Francisco: 4
records in Jan, 6 records in Feb, 1 record in Mar etc.

My plan was to base the layout on the primary table (with a sub-
summary part sorted by city), but I'm stymied by how to get the
records-per-month data into the vertical columns in any kind of an
elegant manner (without too many subsidiary tables, added fields,
etc.).

I'm sure this is a common challenge, and that there's a 'best-
practice' way of achieving it. My hope is that some kind expert out
there will see this and enlighten me!!

The client is using FM9, with FM 9 Server (all windows xp).

Many thanks in advance.

Reply With Quote
  #2  
Old   
Lynn Allen
 
Posts: n/a

Default Re: How to build an array with data from a single table?X-TraceApproved - 12-07-2011 , 05:49 PM






On 2011-12-07 14:59:43 -0800, lansingoogle <ls (AT) jillo (DOT) com> said:

Quote:
I have a client that wants an excel-style report composed of data from
a single table. In this case, the records contain "city" data and
creation dates, and they want a report that will have cities
populating the 'rows', and records-per-month populating the columns
(columns would be Jan, Feb, March, etc.). So... San Francisco: 4
records in Jan, 6 records in Feb, 1 record in Mar etc.

My plan was to base the layout on the primary table (with a sub-
summary part sorted by city), but I'm stymied by how to get the
records-per-month data into the vertical columns in any kind of an
elegant manner (without too many subsidiary tables, added fields,
etc.).

I'm sure this is a common challenge, and that there's a 'best-
practice' way of achieving it. My hope is that some kind expert out
there will see this and enlighten me!!

The client is using FM9, with FM 9 Server (all windows xp).

Many thanks in advance.
I don't think you can use Virtual Lists in FM9, as the GetValue
function didn't exist then. Do you think you can get them to upgrade,
at least the client machines if not the server? (if my recall is
faulty and GetValue exists, go for it).

Virtual lists make such a report relatively easy. You make records in a
reporting table, each one with a serial number. A field for each column
reads an indexed value from a variable with a calc such as
GetValue($$column1array, Serial).

Then you build the variables by looping through the records and setting
the values you want into the lines of the variables. So if your column
1 is city names, then you'd loop through the records and the variable
looks like this:

Chicago
Detroit
Los Angeles
Phoenix

So the calc field in column1, record #2 reads "Detroit."

Then you repeat this for each monthly value (column) you want. Column2,
March 2011, for example might read:

134
148

789

Am I making any sense? Virtual lists are a very powerful tool. I've
done the above kind of cross-tab report getting summary data by doing
finds using the values in the first variable, then setting the found
set totals into the other variables as needed. Think of each variable
as a column in an array.

Because all this is taking place in the memory space of the file, it
goes really really fast. UNLESS you have very large data sets. At more
than 2000 records, creating the arrays by setting them to themselves
plus the new line of data starts to get slow.

If you need subsummaries in the reporting table, create them there, to
total the columns. They'll be fast too.
--
Lynn Allen
--
www.semiotics.com
Member FBA
FM 10 Certified Developer

Reply With Quote
  #3  
Old   
Christoph Kaufmann
 
Posts: n/a

Default Re: How to build an array with data from a single table? - 12-08-2011 , 12:32 AM



lansingoogle <ls (AT) jillo (DOT) com> wrote:

Quote:
I have a client that wants an excel-style report composed of data from
a single table. In this case, the records contain "city" data and
creation dates, and they want a report that will have cities
populating the 'rows', and records-per-month populating the columns
(columns would be Jan, Feb, March, etc.). So... San Francisco: 4
records in Jan, 6 records in Feb, 1 record in Mar etc.

My plan was to base the layout on the primary table (with a sub-
summary part sorted by city), but I'm stymied by how to get the
records-per-month data into the vertical columns in any kind of an
elegant manner (without too many subsidiary tables, added fields,
etc.).
Create global fields for the year and the month. Build a reation to a
second table occurence where the city matches, and the global fields for
year and month on the left side with the data fields for year and month
with the right side.

You can now create a calc field to get the month's total for the city
with the sum function.
--
http://clk.ch

Reply With Quote
  #4  
Old   
lansingoogle
 
Posts: n/a

Default Re: How to build an array with data from a single table? - 12-09-2011 , 06:29 PM



On Dec 8, 1:32*am, clkaufm... (AT) gmx (DOT) ch (Christoph Kaufmann) wrote:
Quote:
lansingoogle <l... (AT) jillo (DOT) com> wrote:
I have a client that wants an excel-style report composed of data from
a single table. *In this case, the records contain "city" data and
creation dates, and they want a report that will have cities
populating the 'rows', and records-per-month populating the columns
(columns would be Jan, Feb, March, etc.). *So... San Francisco: 4
records in Jan, 6 records in Feb, 1 record in Mar etc.

My plan was to base the layout on the primary table (with a sub-
summary part sorted by city), but I'm stymied by how to get the
records-per-month data into the vertical columns in any kind of an
elegant manner (without too many subsidiary tables, added fields,
etc.).

Create global fields for the year and the month. Build a reation to a
second table occurence where the city matches, and the global fields for
year and month on the left side with the data fields for year and month
with the right side.

You can now create a calc field to get the month's total for the city
with the sum function.
--http://clk.ch
Thank you Christopher. At the moment I'm caught up in the strange
world of Virtual Tables that Lynn alerted me to. Your approach is
probably closer to what I would naturally gravitate towards - though
I'm not certain I'm smart enough to fill in the unspoken assumptions.
But I'll give it a whirl...

THANKS!!!

Reply With Quote
  #5  
Old   
lansingoogle
 
Posts: n/a

Default Re: How to build an array with data from a single table? - 12-09-2011 , 07:29 PM



On Dec 7, 6:49*pm, Lynn Allen <l... (AT) NOT-semiotics (DOT) com> wrote:
Quote:
On 2011-12-07 14:59:43 -0800, lansingoogle <l... (AT) jillo (DOT) com> said:


I have a client that wants an excel-style report composed of data from
a single table. *In this case, the records contain "city" data and
creation dates, and they want a report that will have cities
populating the 'rows', and records-per-month populating the columns
(columns would be Jan, Feb, March, etc.). *So... San Francisco: 4
records in Jan, 6 records in Feb, 1 record in Mar etc.

My plan was to base the layout on the primary table (with a sub-
summary part sorted by city), but I'm stymied by how to get the
records-per-month data into the vertical columns in any kind of an
elegant manner (without too many subsidiary tables, added fields,
etc.).

I'm sure this is a common challenge, and that there's a 'best-
practice' way of achieving it. *My hope is that some kind expert out
there will see this and enlighten me!!

The client is using FM9, with FM 9 Server (all windows xp).

Many thanks in advance.

I don't think you can use Virtual Lists in FM9, as the GetValue
function didn't exist then. Do you think you can get them to upgrade,
at least the client machines if not the server? *(if my recall is
faulty and GetValue exists, go for it).

Virtual lists make such a report relatively easy. You make records in a
reporting table, each one with a serial number. A field for each column
reads an indexed value from a variable with a calc such as
GetValue($$column1array, Serial).

Then you build the variables by looping through the records and setting
the values you want into the lines of the variables. So if your column
1 is city names, then you'd loop through the records and the variable
looks like this:

Chicago
Detroit
Los Angeles
Phoenix

So the calc field in column1, record #2 reads "Detroit."

Then you repeat this for each monthly value (column) you want. Column2,
March 2011, for example might read:

134
148

789

Am I making any sense? Virtual lists are a very powerful tool. I've
done the above kind of cross-tab report getting summary data by doing
finds using the values in the first variable, then setting the found
set totals into the other variables as needed. Think of each variable
as a column in an array.

Because all this is taking place in the memory space of the file, it
goes really really fast. *UNLESS you have very large data sets. At more
than 2000 records, creating the arrays by setting them to themselves
plus the new line of data starts to get slow.

If you need subsummaries in the reporting table, create them there, to
total the columns. They'll be fast too.
--
Lynn Allen
--www.semiotics.com
Member FBA
FM 10 Certified Developer

Thanks, Lynn - you introduced me to a whole world of possibilities
here. GetValue is indeed included in v.9, and I'm busily looking into
all the information I can find on Virtual Lists. As a self-taught,
part-time FM developer, who doesn't participate in the big scary world
of major FM development, I was totally unaware of this technique, and
I've spent the last day trying to wrap my head around the
implications. Actually, it captures the essence of why I enjoy
Filemaker, and the community it engenders: flexibility, innovation,
and a creativity that continually amazes me (not to mention a
generous, unselfish willingness on the part of the experts to share
their knowledge).

Again, Thanks.

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.