Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
devans_1
Creator
Creator

Num () question

I have some data that has been created using SUM (). Some of it is integer, some of it is not. I would like integers displayed without decimal places. But I would like the data that contains decimal places to stop at 2 dp. e.g. Data of

1

2

3.45678

would display as

1

2

3.46

If I just display the data, I get

1

2

3.45678

If I use the NUM function (ie NUM (<field>, '#,##'), I get

1.00

2.00

3.46

Does anyone know what I am doing wrong with NUM ? My understanding was that the use of the hash meant the decimal places were flexible and would not appear if they weren't there but they are appearing.

13 Replies
Not applicable

NUM (<field>, '#,##') , This format works, but don't set any number setting (dont override document settings)on the chart for this field.


ToniKautto
Employee
Employee

My recommendation is to avoid using text function like Subfield(), since text operations are significantly slower in performance than numerical operations.

With Frac() it is possible to remove the integer part from a value, and if the decimal part is not 0 then the value is a decimal value and should be rounded.

Notice that Round() will adapt both the visible value and the underlying value, while Num() will keep the underlying decimal value and just adapt the visual value. So the selected function to adapt the value depends on what precision you want to have on calculations.

LOAD

  If(Frac(F1)<>0,Round(F1,'0.01'),F1) AS F1

Inline [

F1

1

2

3.45678

];

PrashantSangle

Hi,

Try this,

=if(len(fmod(field,10))>1,num(field,'##.##'),num(field,''))

Regards,

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
its_anandrjs

Otherwise you can simply try with

Num(YourFieldHere,'##.##') as NewNum;