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.

mvp_badge
MVP
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

Rui Barradas wrote:

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 neares 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

 Thank you, this worked perfectly!!!!

 

Rui Barradas wrote:

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 neares 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

 Hi Rui - if I wanted to put a dash (-) anywhere there may be a zero, how would I do that?  Right now, it shows 0k, which on a mobile device looks like a bunch of ok's  : )

Is there a way in the expression itself or the oml to put in a dash if its zero?

 

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.


 

Shailendra Phadke wrote:

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.


 

 

 Thanks for the reply.  It will be any value and never fixed, I want the logic where it can round to the nearest 1000 and place the K to represent 1000.

32341 would be 32K

36541 would be 37K

1235 would be 1k

I would also want someone to show me how to do it to the nearest 100 in case the client would want that instead

32341 would be 32.3K

36551 would be 36.6K

1235 would be 1.2K

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. 

mvp_badge
MVP

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

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

Peter Goyal wrote:

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

 

 The aggregate would return the the number, example 3200, so when you're displaying this in your screen with an expression, would be MyFunction(TheAggregate.TheValue) 

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

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

mvp_badge
MVP

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

mvp_badge
MVP
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

Rui Barradas wrote:

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 neares 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

 Thank you, this worked perfectly!!!!

 

Rui Barradas wrote:

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 neares 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

 Hi Rui - if I wanted to put a dash (-) anywhere there may be a zero, how would I do that?  Right now, it shows 0k, which on a mobile device looks like a bunch of ok's  : )

Is there a way in the expression itself or the oml to put in a dash if its zero?

 

mvp_badge
MVP

You're most welcome Peter :)


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


Kind regards,

Rui Barradas

mvp_badge
MVP

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

Rui Barradas wrote:

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

 Hi!  Thanks!  Where in the oml did you put the logic to do the dash, just so I can learn, I dont want to just copy and paste it in, I couldnt find it in the JS node...

 

mvp_badge
MVP

Hi Peter,

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

Kind regards,

Rui Barradas

Rui Barradas wrote:

Hi Peter,

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

Kind regards,

Rui Barradas

 Perfect!  I guess I will add that same logic to the other client action as well, for the format value nearest 100  : )


Thank you again for all your help!!!!

 

mvp_badge
MVP

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

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.