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: 
Not applicable

Converting Text to Number

Hi,
Im in the process of pulling web data and the data is being pulled all in text format, i am looking for a way to change the Min and Max temperature from the weather tables i have pulled into Num format so i can put it into a chart as currently it doesn't work.

LOAD @1 as PH_Direction,

     @2 as PH_Speed,

     @3 as PH_Time,

     @4 as PH_UV,

     @5 as PH_RAmount,

     @6 as PH_CoR,

     @7 as PH_Min,

     @8 as PH_Max,

     @9 as PH_Summary,

     @10 as PH_Date

This is what i currently have for this section. PH_Min and PH_Max are Min and Max temperatures.

Cannot seem to find an appropriate answer on the community

13 Replies
trdandamudi
Master II
Master II

if you want to convert into numeric then:

Num(fieldName)

swuehl
MVP
MVP

Look into number interpretation functions like Num#(), for example

LOAD

..

     Num#(@7,'#,00',',','.') as PH_Min,

     Num#(@8,'#,00',',','.') as PH_Max,

On Format Codes for Numbers and Dates

Not applicable
Author

Thanks, it seems to be working however since the data being pulled is displayed like this
19°C
it displays it as a "-" in the table.
How do i format it to remove the " °C " at the end

MarcoWedel

can you post a sample of your data and your format variables as well?

thanks

regards

Marco

MarcoWedel

PurgeChar(@7,'°C') as PH_Min

swuehl
MVP
MVP

Maybe use purgechar()

PurgeChar(FIELD,'°C') As FIELD

MarcoWedel

or to keep the unit but get a dual value (incl. underlying numerical value):

Dual(@7, PurgeChar(@7,'°C')) as PH_Min


hope this helps


regards


Marco

Not applicable
Author

Im having difficulty uploading my QVW file as there doesnt seem to be anywhere to do it, but my entire script for that section is

//......................................Port Hedland

LOAD @1 as PH_Direction,

     @2 as PH_Speed,

     @3 as PH_Time,

     @4 as PH_UV,

     @5 as PH_RAmount,

     @6 as PH_CoR,

     @7 as PH_Min,

     @8 as PH_Max,

     @9 as PH_Summary,

     @10 as PH_Date

FROM

[http://www.weatherzone.com.au/wa/pilbara/port-hedland]

(html, codepage is 1252, no labels, table is @6, filters(

Remove(Row, Pos(Top, 13)),

Remove(Row, Pos(Top, 12)),

Remove(Row, Pos(Top, 8)),

Remove(Col, Pos(Top, 15)),

Remove(Col, Pos(Top, 13)),

Remove(Col, Pos(Top, 11)),

Remove(Col, Pos(Top, 9)),

Remove(Col, Pos(Top, 7)),

Remove(Col, Pos(Top, 5)),

Remove(Col, Pos(Top, 3)),

Rotate(right),

Remove(Row, Pos(Top, 1))

));

PH_Date PH_Summary PH_Max PH_Min PH_CoR PH_Direction PH_RAmount PH_UV PH_Speed
FriMay 20Sunny33°C21°C20%E< 1mmHigh13km/h
SatMay 21Increasing sunshine31°C22°C10%WNW< 1mmVery High9km/h
SunMay 22Mostly sunny32°C19°C30%SSE< 1mmHigh20km/h
ThuMay 26Sunny30°C20°C40%SSE< 1mm 9km/h
MonMay 23Sunny32°C20°C30%ESE< 1mmHigh28km/h
TueMay 24Sunny31°C19°C10%ESE< 1mmHigh15km/h
WedMay 25Sunny30°C21°C30%SE< 1mm 10km/h

So i would like to be able to have the temperatures and other numbers in a number format so i can chart them. if i format them at the moment using Num() the field will show up as "-" so i need to be able to remove °C from each

Not applicable
Author

The dual didn't seem to do anything? although the PurgeChar by itself seemed to work perfectly!