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: 
p_verkooijen
Partner - Specialist
Partner - Specialist

Qlik keeps formatting numbers based on first match

Got a MSSQL database with numbers formatted with or without a prefix 0

p_verkooijen_0-1686831730525.png

 

QlikView May 2022SR2 formats the numbers based on sort order. First row is the winner..

Qlik Script:

p_verkooijen_1-1686831902825.png

 

Output

 

LEN en TEXT display's the difference in LEN and content

Order by ID ASC all EANcode's become 0850010131146

Order by ID DESC all EANcode's become 850010131146

p_verkooijen_2-1686831915567.png

 

 

Labels (1)
11 Replies
Or
MVP
MVP

This seems a little silly, but it also doesn't seem too important - you can explicitly set the format you want anyway, so the default shouldn't matter too much? This is also an unsupported version of QlikView (though I imagine the same issue would occur in the newest version). Probably would be best to confirm this with the latest version and open a bug with support if it still happens?

p_verkooijen
Partner - Specialist
Partner - Specialist
Author

Hi @Or 

Although it does not seem to be a too important issue based on the example data but it really is. This is not the only occurrence. The default should remain the source format.

Its just not the same number and gives a lot of issues down the road matching values and creating the correct output. Turning the content to TEXT same, exports will be TEXT. 

I see I typed May2021 SR2 instead of May2022 SR2 . (2021 just recently got EOS on May 25, 2023), Tested with May2022SR2, May2023 IR and same issue. Also tested backwards with April2020 and April2019 SR4 all have the same issue output.

Create a Ticket was the next step.

p_verkooijen
Partner - Specialist
Partner - Specialist
Author

Another test, did a SQL Select and store as seperate dataset into QVD

Loading QVD's same issue, the first format still wins

p_verkooijen_0-1686836066950.png

p_verkooijen_1-1686836079108.png

 

 

 

p_verkooijen
Partner - Specialist
Partner - Specialist
Author

Tested loading these QVD's using Qlik Sense 2023IR

same 😞 

load * from C:\Temp\tmp1.qvd (qvd);
load * from C:\Temp\tmp2.qvd (qvd);

p_verkooijen_2-1686836293770.png

load * from C:\Temp\tmp2.qvd (qvd);
load * from C:\Temp\tmp1.qvd (qvd);

p_verkooijen_3-1686836361104.png

 

p_verkooijen
Partner - Specialist
Partner - Specialist
Author

Created the ticket, for now I fixed it by checking the LEN( vs LEN(NUM(

Because the NUM on load shows the correct length, the prefixed with 0 is 13 and the rest is 12. 

IF(LEN(EANcode)<>LEN(NUM(EANcode)), TEXT(EANcode), EANcode) AS EANcode,

p_verkooijen
Partner - Specialist
Partner - Specialist
Author

ElisaF
Contributor III
Contributor III

Hi  @p_verkooijen 

Another solution is to use Rob's scripting technique - from the link below:
https://qlikviewcookbook.com/2016/07/touchless-formatting/

In the case of your example, test the script below:


TempFormatTable:
LOAD
TEXT('0') as EANcode
AutoGenerate 1;

Data:
LOAD
ID as ID,
EANcode AS EANcode
from .....
;

DROP Table TempFormatTable;

 

p_verkooijen
Partner - Specialist
Partner - Specialist
Author

@ElisaF thnx but that is not going to work. I want the value to remain 085xxxxx or 85xxxxx

Using you example it will only be 085


As my solution shows, I have to check the length and use TEXT or NUM accordingly to get the full number

ElisaF
Contributor III
Contributor III

Hi,

Very strange. I checked the technical solution on QlikView 11.20 SR2 and QlikSense Aug 2023 Patch 3.

The script is as follows:

TempFormatTable:
LOAD
TEXT('0') as EANcode
AutoGenerate 1;


Data:
LOAD
ID                                   AS ID,
EANcode                   AS EANcode,
TEXT(EANcode)     AS EANcode_Text // Desire Output
;
LOAD * Inline [
ID , EANcode
100, 850010131146
101, 0850010131146
102, 0850010131147
103, 850010131147
];


DROP Table TempFormatTable;

 

Ouput:

Liza_2028_0-1698672392295.png

If you get the same output with the script above, I recommend in the SQL syntax to convert EANCode to varchar.
Although I don't think this is the cause.