Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Eli181
Contributor II
Contributor II

Scientific Notation

Greetings:

I am having a very basic problem for which I did not find any answers online:

I need to convert numbers into their scientific notation, that I can tailor with the right number of decimals. In other words and for example:

Turn

1,867,343,087 into 1.87e+9

or 1,123 into 1.1e+3

What is the syntax that

  1. turn numbers into e+ expression, AND
  2. fix the number of decimals, before the e symbol?

Thank you for your help.

 

Can 

Labels (2)
5 Replies
Levi_Turner
Employee
Employee

Hey there,

Does this satisfy things?

Source data:

[table]:
LOAD * INLINE [
values
1003
99035
112341235
];

 

Levi_Turner_0-1619806263539.png

 

One Decimal Expression: 

=left([values],1) & '.' & Right(Left([values],2),1) & 'e+' & (len([values])-1)

Two Decimal Expression: 

=left([values],1) & '.' & Right(Left([values],3),2) & 'e+' & (len([values])-1)

Strictly speaking it doesn't satisfy the rules of scientific notation since you'd want the 2nd digit to not be 0 if my memory of this in high school is accurate!

Eli181
Contributor II
Contributor II
Author

Hi. 

Thank you for your quick answer.

The creation of a new variable in the editor, according to your suggestion, works perfectly when I display value in a table ...

... but it does not work in a chart; it still displays it with a regular numbers format. I tried to apply your formula on a measure too. Still returns the non-scientific notation ...  It seems that the chart only understands the format pattern box

Eli181_0-1619810245684.png

 

Levi_Turner
Employee
Employee

How are you planning on visualizing this data? Because you can always wrap things in =text() and declare it in the script:

[table]:
LOAD * INLINE [
values
1003
99035
112341235
];


[table2]:
NoConcatenate
LOAD
	*,
    Text(left([values],1) & '.' & Right(Left([values],2),1) & 'e+' & (len([values])-1)) AS OneDecimal,
    Text(left([values],1) & '.' & Right(Left([values],3),2) & 'e+' & (len([values])-1)) AS TwoDecimal;
LOAD 
	*
RESIDENT [table];

DROP TABLE [table];
Eli181
Contributor II
Contributor II
Author

Using exactly the same variable ...

Eli181_0-1619812651755.png

 

Cannot use text, because it will not plot

marcus_sommer

You could try to use:

dual(CustomizedScientificNotation, pure numeric value)

as expression.

- Marcus