TRUNC function in Math column or send results to sheet?

Is there a way to take values created in a glide math column and pull out just the decimal (as in TRUNC function in sheets)?

Failing that, is there any way at all to get values computed in a math column back into the Google sheet?

I need to grab the decimal hanging off of whole number results so that I can use that as a percentage for a progress bar.

Also, is there any way to get the progress bars to have individual colors for both the bar and background, and maybe a percentage complete dialogue like the circle and arc progress indicators?

  • Create a math column that takes the calculated value with the decimal and rounds it to a whole number.
  • Create a template column that takes the math column and “locks in” the rounded value
  • Create a math column that subtracts the original value from the template column value.

Unless I misunderstood. Do you just want the value rounded to a whole number? You can do that in data editor by clicking on the column and setting the precision (rounding).

You can’t alter the color scheme of a progress bar. It is set to match the color scheme of the app. Unless you are willing to mess with the CSS formatting, which in my opinion, is unreliable and can easily break.

For a percentage complete dialog, you can simply create a template column with the text you want.

2 Likes

I don’t need a rounded number. That’s the problem. I need to round down (so I can use subtraction) or get the REMAINDER as a decimel after you remove the whole number. Examples:

12.7 -12.0 = 0.7
5.2 -5.0 = 0.2

The “precision” setting in a number column seems to round off, not down.

Hmmm, I’ll have to think about that. I’m pretty sure that’s not currently possible in glide, but I’m trying to think of a magic math formula in combination with existing glide functions that could do it somehow. If I think of something, I’ll let you know.

1 Like

Check out the concept I made here in the Trunc test tab.

What I did behind the scenes, assuming Dave only needs positive numbers as inputs.

A math column & template column to round the number up to integer.

A delta column = number - integer temp.

The helper column is 1 + delta column.

Final value: If delta less than 0 then helper, if delta equals 0 then 0, else delta.

2 Likes

That looks like it will work. It’s a brilliant solution. I’ll test it tomorrow.

I mean, it’s a kludge to have to workaround like this for something so simple, but this is more elegant than what my brain was capable of tonight after 6+ hours of glide building.

1 Like

Yes I agree, it would be nice to have this support natively, I have had to use so many columns for workarounds related to math. At least it’s nice to keep it inside Glide.

Or maybe for a couple less columns: a math column that is (original number - 0.5) to zero decimal places, a template column to lock it in, and then (locked in value - original value.

Edit: changed 0.499, which is technically incorrect, to 0.5

1 Like

Nice work @ThinhDinh . I knew there had to be a roundabout way. I had to do something similar awhile back, but a different scenario. In my case 2 values were joined together to form a number with a decimal, but later needed to split it apart without rounding as well. The whole number is miles and the decimal is ‘chains’, where 80 chains is equal to 1 mile. I had converted the 80 chains to 10 based decimal so we could sum total chains and let it also increment the miles. Then later separate the whole number (miles) and decimal (chains) so I could convert the decimal form of chains back into it’s own whole number form by multiplying it by 80.

Looks to be very similar, but in my case I think I rounded the original value, then created a second value of the rounded number - 1. Then I subtracted the rounded value from the original number. If negative (due to rounding up), then I used the column with the number -1. If positive, then I used the original rounded column since it rounded down. That gave me the final whole number value and I subtracted that from the original value to get the chains decimal value by itself.

1 Like

This works great unless the current value is 0, which returns problematic results. Unfortunately, the starting value for this function will be 0 unless students are choosing to donate funds into a particular asset.

This tests correctly, including when the input value is 0. Thanks again! Hope the kids like the working progress bars!

1 Like