Hot Topic (More than 10 Replies) Changing bound-to type of derived columns (Read 2342 times)
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Changing bound-to type of derived columns
Apr 3rd, 2007 at 7:21pm
Print Post Print Post  
Most, if not all, of my derived columns have been translated into Text type since the conversion from Q&A.  Can someone point me to a guide page that tells me how to change the type?  Thanks.
  

**
Captain Infinity
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Changing bound-to type of derived columns
Reply #1 - Apr 3rd, 2007 at 7:36pm
Print Post Print Post  
Select the Unbound Element.

On the Format tab of the Property Editor, select the type you want from the Format Unbound As dropdown.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: Changing bound-to type of derived columns
Reply #2 - Apr 3rd, 2007 at 8:14pm
Print Post Print Post  
If these are already bound then you can use the Database Manager.

You may want to make a backup before you make the changes.

Select Manage a Database
Select the database
Select Manage Fields
On the right side, under Transaction Builder, select Change Field Type
In the box for Field Name, select the field name that you want to change
In the box for Field Type, select the new Type that you want to use.
Add the transaction to the Batch

Repeat as necessary for all fields whose type you need to change.

Run the batch.

----------------------------
Remember that some programming may need to change to support the different types vs. text.

========================
OOPS!
Just noticed my reply was for elements on Forms.  You were talking about Derived Columns on Reports.
Sorry about that.........
  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: Changing bound-to type of derived columns
Reply #3 - Apr 3rd, 2007 at 8:48pm
Print Post Print Post  
Ah, UNbound!  That's what's been tripping me up.  These are all bound to the column names, things like !(30-60 days).  No wonder Sesame is flipping out.  Once I removed the binding I could change the type.  Thanks Erika!  (Now watch me forget how to do this and ask again in a month.)

And thanks, Bob, I saw what you were saying (and had already tried that with no luck, of course).

My next question, unrelated to types and binding, but still dealing with derived columns, is this:  Can a derived column do a call-out comparison to a value stored in a text file on disk?

Here's my situation:  my boss likes to run a "monthly billed" report.  This report lists all the invoices billed this month, with 2 derived columns.  One is a running total, (which is giving me a little trouble.  In Q&A the derived column uses the programming
Code
Select All
 Running_Total = Invoice_Amount + Running_Total 


which works fine in Q&A but is doubling the amount of the first invoice in Sesame.  I need to whack away at it a little, see what I'm doing wrong, get it to start from zero somehow.)

The other column is "needed to tie", which compares the running total to the total amount of LAST YEAR'S current month invoices.  In Q&A each month I have to go in and redesign the report and hard code in the amount of, say, last April's billing.  So say we billed $500,000.00 last April, the programming would be:
Code
Select All
 Needed_to_Tie = 500000.00 - Running_Total 


and this nicely counts down as invoices are added during the month, hopefully eventually becoming zero and then a negative if we do more business than last April.

Now, since Sesame can read from external files, it would be a heck of a lot easier for me to store that $500,000.00 value in a text file, and tell the report to go look at the value in that file and then subtract Running_Total from it.  That way I could change the figure on the fly each month at whim, and not have to go into report designer, redesign, save, reconcile, the whole bit.

So....is this do-able, or am I dreaming?
  

**
Captain Infinity
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Changing bound-to type of derived columns
Reply #4 - Apr 3rd, 2007 at 8:57pm
Print Post Print Post  
Infinity wrote on Apr 3rd, 2007 at 8:48pm:
Here's my situation:  my boss likes to run a "monthly billed" report.  This report lists all the invoices billed this month, with 2 derived columns.  One is a running total, (which is giving me a little trouble.  In Q&A the derived column uses the programming
Code:

Running_Total = Invoice_Amount + Running_Total



which works fine in Q&A but is doubling the amount of the first invoice in Sesame.  I need to whack away at it a little, see what I'm doing wrong, get it to start from zero somehow.)


Make sure that Running Total is not bound to anything. You could also try adding
Code
Select All
Running_Total = 0 

in Global Code.

Quote:
......Now, since Sesame can read from external files, it would be a heck of a lot easier for me to store that $500,000.00 value in a text file, and tell the report to go look at the value in that file and then subtract Running_Total from it.  That way I could change the figure on the fly each month at whim, and not have to go into report designer, redesign, save, reconcile, the whole bit.

So....is this do-able, or am I dreaming?


Something like this.

Code
Select All
Var vAmount as Int

vAmount = @ToNumber(@Insert("A_Text_File.txt"))
Needed_to_Tie = vAmount - Running_Total 



-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: Changing bound-to type of derived columns
Reply #5 - Apr 3rd, 2007 at 8:59pm
Print Post Print Post  
Thanks Ray, I'll give it a try first thing tomorrow.
  

**
Captain Infinity
Back to top
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: Changing bound-to type of derived columns
Reply #6 - Apr 4th, 2007 at 12:56am
Print Post Print Post  
How about setting up a Global Variable to hold last month's billling, vAmount = $500,000.
Then just change the value of the Global Variable at the end of each billing cycle.  No need for external files.

I frequently have a one record database for Company where I can store various values for lookups, comparisons, etc.  It includes the normal address/fax/web site info, Fed and State Tax ID, and any other fields that might be somewhat constant and used in reports, headers, etc..  In yours case, could include fields for Billings: MTD, YTD, Last Month.  These would all be updated at the end of each month, but be available to include in reports, analysis, etc. during the month.
  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: Changing bound-to type of derived columns
Reply #7 - Apr 4th, 2007 at 12:17pm
Print Post Print Post  
Thanks, Bob, that's intriguing.  Would an XLookup from a report's derived column be done differently than an XLookup in a form's programming?
  

**
Captain Infinity
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Changing bound-to type of derived columns
Reply #8 - Apr 4th, 2007 at 1:10pm
Print Post Print Post  
Infinity wrote on Apr 4th, 2007 at 12:17pm:
Would an XLookup from a report's derived column be done differently than an XLookup in a form's programming?


Syntax would be the same, only the names of the elements may change.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: Changing bound-to type of derived columns
Reply #9 - Apr 4th, 2007 at 2:07pm
Print Post Print Post  
Wow, you guys have really got me thinking.  Would it be possible to craft an xlookup that takes its argument based on the current month name, using @month to key on an external field?  If so, I could store a year's worth of monthly totals in an external database in 12 different fields, each named for a different month.
  

**
Captain Infinity
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Changing bound-to type of derived columns
Reply #10 - Apr 4th, 2007 at 2:29pm
Print Post Print Post  
Code
Select All
Var MonthTotal as Int

MonthTotal = @ToNumber(@XLookup("Data\Totals.db", @Year(@Date), "Year", @Month$(@Date))) 



You mean something like that? Nah it's not possible Wink

You can even store history for past years in there, since it retrieves for the current year.

-Ray
« Last Edit: Apr 4th, 2007 at 6:24pm by Ray the Reaper »  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: Changing bound-to type of derived columns
Reply #11 - Apr 4th, 2007 at 3:00pm
Print Post Print Post  
That looks beautiful, but yes, last year's figures are what I would be storing.  So, maybe:
Code
Select All
Var MonthTotal as Int
MonthTotal = @XLookup("Data\Totals.db", @Year(@Date) - 1, "Year", @Month$(@Date)) 


What should I name the external fields?  I really only need to look a year back.  Would I just give them month names?
  

**
Captain Infinity
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Changing bound-to type of derived columns
Reply #12 - Apr 4th, 2007 at 3:35pm
Print Post Print Post  
It would be a Number Field.
And you would name the external fields the month names as that is what @Month$() returns.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: Changing bound-to type of derived columns
Reply #13 - Apr 4th, 2007 at 3:36pm
Print Post Print Post  
Thanks Ray, I'll let you know how it works out.
  

**
Captain Infinity
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: Changing bound-to type of derived columns
Reply #14 - Apr 4th, 2007 at 5:58pm
Print Post Print Post  
After much trial and error, I got the following to work:
Code
Select All
Var MonthTotal as Double

MonthTotal = @XLookup("C:\Sesame\Miara\MonthTotals.db", @Year(@Date) - 1, "Year", @Month$(@Date))
Writeln(MonthTotal)
Needed_to_Tie = (MonthTotal - Running_Total) 


As you can see, I needed to specify Double so MonthTotal wouldn't truncate the cents.  The Writeln is there because I wanted to see what figure the XLookup was pulling out of the external database; for the longest time my "needed to tie" figure was $10,307,921.48 or so, a number I always see when 0 (zero) is involved somehow and mucking things up.  What finally fixed it, and got me a successful retrieve, was spelling out the complete path to MonthTotals.db (Sesame didn't like the relative at all, even though my main app and MonthTotals.db are in the same directory).

I'm still doubling the value of the first invoice in my Running_Total column; setting Running_Total = 0 in Global code did not change this.

Getting closer, though.  And after this one, I only have about 4 dozen more reports to go!  And I'm nowhere near making them look pretty! (All the columns run together.)  Wheee!
  

**
Captain Infinity
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: Changing bound-to type of derived columns
Reply #15 - Apr 4th, 2007 at 6:27pm
Print Post Print Post  
Found out what was going wrong with Running_Total.  I had both "Running_Total" and "COLUMN Running_Total" programmed.  I took out the programming in "COLUMN Running_Total" and the doubling stopped.

Thanks for all your help, Ray.
  

**
Captain Infinity
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Changing bound-to type of derived columns
Reply #16 - Apr 4th, 2007 at 6:30pm
Print Post Print Post  
Infinity wrote on Apr 4th, 2007 at 5:58pm:
What finally fixed it, and got me a successful retrieve, was spelling out the complete path to MonthTotals.db (Sesame didn't like the relative at all, even though my main app and MonthTotals.db are in the same directory).


The relative path needs to be from the CWD of the Sesame Executable so if the CWD of Sesame is C:\Sesame then the relative path would be Miara\MonthTotals.db. The only change I can recommend to that code is to wrap the @XLookup in an @ToNumber() or @ToMoney() that way Sesame is not guessing on how to do the conversion. I forgot it in my code example, sorry about that, too many things at once.

Quote:
I'm still doubling the value of the first invoice in my Running_Total column; setting Running_Total = 0 in Global code did not change this.


Hmm. How many events do you have the programming in that adds the value of the invoice to the Running_Total? I'm wondering if perhaps on an element in the group or view header as well as in an element in the group body(which is where it should be)

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: Changing bound-to type of derived columns
Reply #17 - Apr 4th, 2007 at 6:50pm
Print Post Print Post  
Quote:
The relative path needs to be from the CWD of the Sesame Executable so if the CWD of Sesame is C:\Sesame then the relative path would be Miara\MonthTotals.db.

The exe is in C:\Sesame\Program, so I'm not sure how to navigate from there.  But it's not important, because eventually the db will be on the server, and I'm sure that will change everything.  For now it's no trouble to point straight at it, the lookup is working well, thanks again for your guidance.
Quote:
The only change I can recommend to that code is to wrap the @XLookup in an @ToNumber() or @ToMoney() that way Sesame is not guessing on how to do the conversion. I forgot it in my code example, sorry about that, too many things at once.

I have now done that, @ToMoney, and thanks for the suggestion.  I'm going to post a note above my monitor to remind me to specify these things in the future so I don't have to make Sesame do more work than is needed.  Or you, for that matter.  Take a break, you've earned your pay today, the coffee and doughnuts are on me!
Quote:
Hmm. How many events do you have the programming in that adds the value of the invoice to the Running_Total? I'm wondering if perhaps on an element in the group or view header as well as in an element in the group body(which is where it should be)

You guessed it!  (Or did you peek?) I'm still unfamiliar with programming reports so I wasn't aware of the  "doubling" of header names and elements and didn't scroll far enough down when choosing the element to program, so I was fighting with the Q&A programming that was already there.  These Q&A reports are a pain in the ass, probably easier to start from scratch than try to redesign them all.

Thanks again, Ray, I can't say thanks enough!
  

**
Captain Infinity
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Changing bound-to type of derived columns
Reply #18 - Apr 4th, 2007 at 7:02pm
Print Post Print Post  
Infinity wrote on Apr 4th, 2007 at 6:50pm:
I have now done that, @ToMoney, and thanks for the suggestion.  I'm going to post a note above my monitor to remind me to specify these things in the future so I don't have to make Sesame do more work than is needed.

It's not that Sesame would have to do more work, it's just best to not make Sesame or computers in general guess at what you want them to do.

Quote:
Take a break, you've earned your pay today, the coffee and doughnuts are on me!

Thanks Scott but I got a bit too much work to do right now to take a break.

Quote:
You guessed it!  (Or did you peek?)

Nah I didn't peek, I just guessed it.

Quote:
Thanks again, Ray, I can't say thanks enough!

You are welcome.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: Changing bound-to type of derived columns
Reply #19 - Apr 5th, 2007 at 7:18pm
Print Post Print Post  
I also want to give another shout out to Bob for this:
Quote:
I frequently have a one record database for Company where I can store various values for lookups, comparisons, etc.  It includes the normal address/fax/web site info, Fed and State Tax ID, and any other fields that might be somewhat constant and used in reports, headers, etc..  In yours case, could include fields for Billings: MTD, YTD, Last Month.  These would all be updated at the end of each month, but be available to include in reports, analysis, etc. during the month.

Great idea Bob, it's working beautifully, thanks so much.
  

**
Captain Infinity
Back to top
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: Changing bound-to type of derived columns
Reply #20 - Apr 6th, 2007 at 2:07am
Print Post Print Post  
Glad it was useful.

So you can show us how you are using this at our SANE meeting in May?
  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: Changing bound-to type of derived columns
Reply #21 - Apr 6th, 2007 at 11:10am
Print Post Print Post  
If I can, I will.  Depends on NDA restrictions.
  

**
Captain Infinity
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Changing bound-to type of derived columns
Reply #22 - Apr 6th, 2007 at 12:27pm
Print Post Print Post  
Infinity wrote on Apr 4th, 2007 at 6:50pm:
The exe is in C:\Sesame\Program, so I'm not sure how to navigate from there. 


Scott,

It doesn't matter where the exe is. It matters where your current working directory is. This is the the directory in the Start In property of your shortcut.. If you are running from command line, it is the current directory shown by the command line.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged