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

Simple math - number compression in qlikview

Please don't freak out. This question is small. I only added a lot of notes and sample tables to make it clear.

The following notes are taken from the book - Qlikview 11 for developers - 

For example, if we have a measure that contains integer numbers ranging from 0 to 100,000,000, we can potentially end up with 100 million unique values. As an alternative, we could split the number into two 10,000 (the square root of 100 million) number ranges using the  Div() and  Mod() functions, shown here:

LOAD

Div(BigNumber, 10000) as BigNumber1,

Mod(BigNumber, 10000) as BigNumber2

FROM BigNumber;

The first expression in the preceding code performs an integer division of the value of  BigNumber by 10,000. This means that only the resulting whole number is stored. The second expression performs a modulo operation, storing only the remainder of BigNumber divided by 10,000. Both of these fields have a potential of 10,000 unique values. That's 20,000 possible unique values when combined, or only 0.2 percent of the original list.


---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


Question - This logic does not give me the correct values in qlik view. Why ?


File -


BigNumber

10,001;

10,002;

10,003;

11,0001;

12,0002;

13,0003;


Expected value as per math logic/SQL -

select BigNumber, BigNumber/10000 as Div, BigNumber%10000 as Mods

from BigNumber

BigNumberDivMods
1000111
1000212
1000313
110001111
120002122
130003133

Qlikview output (imagine it as list boxes) -

BigNumber1 {1}

BigNumber2 {1,2,3}


Qlikview Script -


[BigData]:

LOAD

Div(BigNumber, 10000) as BigNumber1,

Mod(BigNumber, 10000) as BigNumber2

FROM

[..\..\..\..\Examples\BigNumberCompress.txt]

(txt, codepage is 1252, embedded labels, delimiter is ';', msq);

Why is  my qlikview giving the wrong result ?

5 Replies
Not applicable
Author

It is working fine for me.

Thanks,

Ram

Not applicable
Author

I added it as a list box, whereas you added it as a table box. Why is the list box not showing the values correctly ?

Thanks.

Not applicable
Author

By the way, my data file has semi-colons at the end of each row, but yours does not.

Not applicable
Author

there you go. Your format and list boxes.

Not applicable
Author

Hi John, Can you mark this thread as "Answered". Thanks.