Skip to main content
Announcements
See why Qlik is a Leader in the 2024 Gartner® Magic Quadrant™ for Analytics & BI Platforms. Download Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Len() not showing the length of my data correctly!

I am using the len() function in a numeric field to reduce the records but the function doesn't seem to be working correctly.

What do you think might be causing this?

Lentrim.png

Len.png

14 Replies
sunny_talwar

Where is gmeternumber? Is it the same thing as MPRN - Gas from the screenshot?

Anonymous
Not applicable
Author

oh yes, I just renamed the lable of the field. And my expression to check the length is

    ,Len(Trim("gmeternumber"))           As Length

sunny_talwar

Something doesn't seem right... can you share the script for this table?

swuehl
MVP
MVP

Is your gmeternumber maybe filled up to a length of 10 with white spaces like chr(160), that won't be trim'med?

(But you can replace it with a '' by using Replace(FIELD,chr(160),'') )

What's the source of the data?

swuehl
MVP
MVP

You can also try an expression in your chart like

=Ord(Mid( FIELD, 5,1))

Ord() returns the Unicode code point number of the first character of the input string.

Mid(FIELD,5,1) will return the 5th character. Play around, change 5 with any number between 1 and 10 to see what your field values characters look like.


edit: corrected copy&paste failure from the Ord() HELP file

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Stefan,

Here's a fun variation of your idea that will display the ord() values of all chars in the string at once:

=concat(

ord(

mid('$(=String)'

,ValueLoop(1,len(String))

,1)

)

,','

)

Caveat:  I've only been able to make this work if there is only a single value for String selected -- because ValueLoop has to be a constant.

-Rob

swuehl
MVP
MVP

Nice idea!

I've used something like

=concat(

ord(

mid(String

,ValueLoop(1,$(=max(len(String))))

,1)

)

,','

,ValueLoop(1,$(=max(len(String))))

)

in a chart with dimension String. (The second Valueloop is handling the correct sort order of the ASCII codes).

If the String shows less then Max length, zero ASCII code number will be added.

swuehl
MVP
MVP

Number Length =concat( ord( mid(Number ,ValueLoop(1,4) ,1) ) ,',' ,ValueLoop(1,4) )
920357,50,48,0
1306449,51,48,54
3203451,50,48,51
3503451,53,48,51
4296452,50,57,54
4361452,51,54,49
4498452,52,57,56
5894453,56,57,52
5969453,57,54,57
6444454,52,52,52
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Cool.  I was trying to get something like this to work for a long time. Here's an update to your expression that doesn't have the extra zeros.  Also handles when same String appears more than once.

=trim(

Replace(

concat(DISTINCT

if(ValueLoop(1,$(=max(len(String)))) <= len(String)

,ord(

mid(String

,ValueLoop(1,$(=max(len(String))))

,1)

)

,''

)

,','

,ValueLoop(1,$(=max(len(String))))

)

,',',' ')

)