18
Views
18
Comments
Solved
Display numeric values

I have a field which is being displayed as 30000.  I want all data to be displayed in 1000's.  So 30k for 30000, 11K for 11361, 12k for 11525K and so forth...can anyone please provide me some guidance please.

Rank: #119
Solution

Hello Peter,

Hope you're doing well.

I believe that you want to achieve something like this:


I made a sample app for you with 2 functions: one to round to the nearest 1000 (called FormatValue) and another one to round to the nearest 100 (called FormatValueNearest100).

In this sample, you can see how to call these created functions in your screen in order to convert the values.


Please refer to attached OML file :)


Hope that this helps you!


Kind regards,

Rui Barradas

NumericValues.oml

Peter Goyal wrote:

I have a field which is being displayed as 30000.  I want all data to be displayed in 1000's.  So 30k for 30000, 11K for 11361, 12k for 11525K and so forth...can anyone please provide me some guidance please.

 Hi Peter,

The values you mentioned are fixed? Or you will any value and accordingly you want an output?

If values are fixed then using if or switch you can do it.


 

Rank: #363

You might need to create your own little function to spit out the thing formatted how you like it.

Take the integer, divide it by 1000, that'll give you the amount of thousands, then test if the remainder is over 500, if so add another 1k to the sum, etc. 

Rank: #95

Hi Peter,


You better create a function to abstract that behavior and to reuse, something like this:


The function divides by a 1000, rounds up to integer and adds the K.

Afterwards you just need to use when you display something on the screen:


Hope it helps.


Cheers,

João

Rank: #3153

How would i call this function if this data is inside an aggregate that is displayed in a table on a screen?

Rank: #363

You will still need to create your own function for what it seems. Welcome to outsystems and functions and code reusability!

Rank: #3153

I understand and I get it.  How do you call a function inside an aggregate which is being displayed on a screen???

Rank: #95

Hi Peter,


You can call it when you display on the screen like this:



Take into account to mark the action has a function:


Once you do that, you can use it as a function on any expression:


Cheers,

João

Rank: #119
Solution

Hello Peter,

Hope you're doing well.

I believe that you want to achieve something like this:


I made a sample app for you with 2 functions: one to round to the nearest 1000 (called FormatValue) and another one to round to the nearest 100 (called FormatValueNearest100).

In this sample, you can see how to call these created functions in your screen in order to convert the values.


Please refer to attached OML file :)


Hope that this helps you!


Kind regards,

Rui Barradas

NumericValues.oml

Rank: #119

You're most welcome Peter :)


Edit to respond to your question: sure thing, give me a couple minutes!


Kind regards,

Rui Barradas

Rank: #119

Hi again Peter,


There you go:


I did these changes directly in the function FormatValue.

Please refer to attached OML file with this changes :)


Kind regards,

Rui Barradas

NumericValues.oml

Rank: #119

Hi Peter,

It is in the Assign widget, after the JavaScript node :)

Kind regards,

Rui Barradas

Rank: #119

Hi again Peter,

Yep, I did those changes only for the first function :)

You may add that same logic to the second function if you want the same behavior.


Happy coding! :)


Kind regards,

Rui Barradas