Qlik Community

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

cancel
Showing results for 
Search instead for 
Did you mean: 
MalcolmCICWF
Creator III
Creator III

Restrict and create new field based on Length

I'm not sure how to word this, but I have an Excel spreadsheet that contains some account numbers that we need to use for reporting purposes. Because this field is manually entered by multiple agents, the data formatting/length is not uniform and contains an array of text and numbers. 

Without going back and fixing the data, is there a way I can limit and pick out only the entries with 10 or less numbers (These are valid)? I have already removed all alpha characters from the mix, but I have data that looks like the below. Can I use the "LEN" function somehow? Anyone have some suggestions?

Capture.JPG

1 Solution

Accepted Solutions
sunny_talwar

Try this may be:

If(Len(Trim(ACCTnum)) <= 10, Num(ACCTnum, '0000000000')) as TEST2

View solution in original post

9 Replies
sunny_talwar

You sure can:

LOAD FieldNames

FROM Source

Where Len(Trim(A)) <= 10;

MalcolmCICWF
Creator III
Creator III
Author

Doesnt work, using this to create a field and see what it contains, but I am getting "-1" and "0" as my only results.

LEN(TRIM(ACCTnum))<=10 as TEST2,

sunny_talwar

To create a field, try this:

If(Len(Trim(ACCTnum)) <= 10, ACCTnum) as TEST2

Colin-Albert

Perhaps create a straight table with ACCTnum as a dimension and then you can test your expression in the chart without needing to reload the data each time.

Try adding the expression len(trim(ACCTnum)) so you can compare the source data and output.

johnw
Champion III
Champion III

0 = false

-1 = true

MalcolmCICWF
Creator III
Creator III
Author

yep, thanks, I am aware of this part.

MalcolmCICWF
Creator III
Creator III
Author

alright, so this sort of seems to be working better.

I have one more question then, with the remaining accounts I have, is there a way to add leading zeros if the account is under 10 digits? I have some accounts left over that are under 10 digits that should have them. Simple formatting change in the field creation??

Ex.  456789    --------> 0000456789

sunny_talwar

Try this may be:

If(Len(Trim(ACCTnum)) <= 10, Num(ACCTnum, '0000000000')) as TEST2

MarcoWedel

Hi,

maybe

LOAD A

FROM YourExcel.xlsx (ooxml, no labels, table is Sheet1)

Where Num(A)<10000000000;

regards

Marco