convert string to number

112 views
Skip to first unread message

Brixter Tabun

unread,
Mar 10, 2020, 12:54:42 PM3/10/20
to mementodatabase
I use memento like a goal tracker. Here's a simple example:

Goal: eat 3 apples a day

I have a numeric field to keep track of the apples and a calculation field that evaluates if I hit my goal.

calculation field: if(#{apples} >= 3, 1, 0) and returns an integer result

My problem is that when I sync it to google sheets, the output of the calculation field is a string. ex. '1. The apostrophe at the beginning of 1 makes it a string instead of a number. If I do a sum(c1:c10) in google sheets, I get a 0 because google thinks that all of the values I'm summing up are strings and not numbers even though the values are either '0 or '1. I assume that the IF logical function returns a string. As a workaround, I can format the column in google sheets as a number but I don't want to do it every time.

How to I convert a string to a number?

Stephen Johnson

unread,
Mar 10, 2020, 1:18:46 PM3/10/20
to mementodatabase
Below your formula in the field is a parameter for how you want the result conveyed. Is it set to "integer" or "real number"?

Another option is display as string. If this is set then that's the problem.

Brixter Tabun

unread,
Mar 10, 2020, 1:27:21 PM3/10/20
to Stephen Johnson, mementodatabase
Hi Stephen,

My calculation field returns an Integer result.

Where can I find the "display as string"? I just started using memento database this week.

Thanks!
Brixter

On Wed, Mar 11, 2020 at 1:18 AM Stephen Johnson <grampa...@gmail.com> wrote:
Below your formula in the field is a parameter for how you want the result conveyed. Is it set to "integer" or "real number"?

Another option is display as string. If this is set then that's the problem.

--
You received this message because you are subscribed to a topic in the Google Groups "mementodatabase" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mementodatabase/ue-FLVdhTZA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mementodataba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mementodatabase/a30db5b7-d3d6-45b7-a0cb-9709ea807c68%40googlegroups.com.
Message has been deleted

Stephen Johnson

unread,
Mar 10, 2020, 1:34:52 PM3/10/20
to mementodatabase
Go to "edit library"
Find your field

Tap the right side (I think it's 3 dots)
Choose "change"

Your equation and current parameters appear. You will see the "Display result as..." just below the equation.

Stephen Johnson

unread,
Mar 10, 2020, 1:37:16 PM3/10/20
to mementodatabase
It doesn't say "Display as"

It's a drop down menu

Brixter Tabun

unread,
Mar 10, 2020, 10:06:25 PM3/10/20
to Stephen Johnson, mementodatabase
Hi Stephen,

There is a dropdown with the possible results: Real, Integer, Date, Date/Time, String result. My calculation field is using Integer result.

Aside from that, there is a "Display as" dropdown with choices: Regular field, Entry name, Entry description, Entry status, Hidden field. I use Regular field.

Are those what you're referring to?

Thanks!
Brixter

On Wed, Mar 11, 2020 at 1:37 AM Stephen Johnson <grampa...@gmail.com> wrote:
It doesn't say "Display as"

It's a drop down menu

--
You received this message because you are subscribed to a topic in the Google Groups "mementodatabase" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mementodatabase/ue-FLVdhTZA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mementodataba...@googlegroups.com.

Stephen Johnson

unread,
Mar 10, 2020, 11:18:56 PM3/10/20
to mementodatabase
Yes, exactly.

If it's set to integer that's what you want, as it could also be used in other calculated fields. Why it is converting to text in your spreadsheet is a conundrum.

I'm pretty new to Memento myself. Maybe change it to real result and see if that helps.

Brixter Tabun

unread,
Mar 10, 2020, 11:40:37 PM3/10/20
to Stephen Johnson, mementodatabase
Hi Stephen,

I tried with the Real result too but the google sheet ends up as string values as well.

Thanks for trying to help. I guess I'll just do my workaround then.

Thanks!
Brixter

--
You received this message because you are subscribed to a topic in the Google Groups "mementodatabase" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mementodatabase/ue-FLVdhTZA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mementodataba...@googlegroups.com.

Stephen Johnson

unread,
Mar 10, 2020, 11:44:29 PM3/10/20
to mementodatabase
That's frustrating.

Try searching for your answer on the help page. Maybe there is an existing solution there.

Many blessings,

Stephen

Bill Crews

unread,
Mar 11, 2020, 1:39:12 AM3/11/20
to Stephen Johnson, mementodatabase
I don't sync to Google Sheets, so I don't know if this will work or not, but you could try using a JavaScript field instead of a Calculation field. Just use one of these simple scripts...

if (field("apples") >= 3) true; else false;   // if you want a Boolean result

if (field("apples") >= 3) 1; else 0;   // if you want an Integer result


--
You received this message because you are subscribed to the Google Groups "mementodatabase" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mementodataba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mementodatabase/1f21cd6c-9995-43d7-891f-0529e9988552%40googlegroups.com.

Brixter Tabun

unread,
Mar 11, 2020, 8:23:06 AM3/11/20
to Bill Crews, Stephen Johnson, mementodatabase
Hi Bill,

I tried that too wit the Javascript field with 1 or 0 but the sync to google sheets gives me a '1 or '0. I guess I'll have to live with it.

Thanks!
Brixter

You received this message because you are subscribed to a topic in the Google Groups "mementodatabase" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mementodatabase/ue-FLVdhTZA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mementodataba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mementodatabase/CAORXpsSXH1Ezfo6xGMO%2BNT2DsOU%3DBHCstY-xDHBBtVqWKoF7ww%40mail.gmail.com.

Bill Crews

unread,
Mar 11, 2020, 12:15:02 PM3/11/20
to Brixter Tabun, Stephen Johnson, mementodatabase
Are you syncing to a pre-existing sheet or to a new sheet? If it's a pre-existing sheet, can you just highlight the column in the sheet and format it as numeric? Even if it's a new sheet, once it's wrong the first time, you could then format it as numeric after that, and thereafter it would sync correctly, no?
Reply all
Reply to author
Forward
0 new messages