Qlik Community

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Now Live: Qlik Sense SaaS Simplified Authoring – Analytics Creation for Everyone: READ DETAILS
cancel
Showing results for 
Search instead for 
Did you mean: 
sridhar_sigired
Creator
Creator

Logical data question - Binary numbers

Hello guys,

Don't know whether right place to ask this question or not. Do help if possible.

I have a list of below distinct values in SOURCE field.

 

SOURCES
100
110
1000
1010
1100
1110
10000
10010
100100
100110

When i check database what these values represents to, comment is available for this field in oracle DB as  "Set as a bit INDEX: 0 = U, 1 = A, 2 = S, 3 = R, 4 = AA, 5 = SS.

I got confirmation for some of values what does those means as below, however i cannot understand what will be the combination of sources for remaining binary numbers. (1000, 1010, 1100, 1110, 10000, 10010, 100100)

   

SOURCERepresentation
100S2
110A+S1+2
1000
1010
1100
1110
10000
10010
100100
100110A+S+SS1+2+5

I have gone though the binary number concepts, but not sure for final results.

Anyone can help how can we know this ?

Thanks alot.

1 Solution

Accepted Solutions
Peter_Cammaert
Partner - Champion III
Partner - Champion III

Bits (or flags if you like) in this bit mask are right-aligned and numbered from right to left, e.g. b5b4b3b2b1b0.

Fifth row

b5b4b3b2b1b0

0 0 1 1 0 0


means bit 3 (R) and bit 2 (S) are set.

View solution in original post

4 Replies
jonathandienst
Partner - Champion III
Partner - Champion III

This will unpack the binary index:

If(SOURCE bitand 1, 'U ', '') &

  If(SOURCE bitand 2, 'A ', '') &

  If(SOURCE bitand 4, 'S ', '') &

  If(SOURCE bitand 8, 'R ', '') &

  If(SOURCE bitand 16, 'AA ', '') &

  If(SOURCE bitand 32, 'SS ', '') As Index

To use + as a spacer and to remove the trailing +:

Replace(

    Trim(

        If(SOURCE bitand 1, 'U ', '') &

            If(SOURCE bitand 2, 'A ', '') &

            If(SOURCE bitand 4, 'S ', '') &

            If(SOURCE bitand 8, 'R ', '') &

            If(SOURCE bitand 16, 'AA ', '') &

            If(SOURCE bitand 32, 'SS ', '')

    )

    , ' ', '+'

)  As  Index

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Peter_Cammaert
Partner - Champion III
Partner - Champion III

Bits (or flags if you like) in this bit mask are right-aligned and numbered from right to left, e.g. b5b4b3b2b1b0.

Fifth row

b5b4b3b2b1b0

0 0 1 1 0 0


means bit 3 (R) and bit 2 (S) are set.

sridhar_sigired
Creator
Creator
Author

Thanks for response.

I can create new field like

If(Source=100, DUAL('S',100),  

If(Source=110, DUAL('A+S',110),   

If(Source=100110, DUAL('A+S+SS',100110)    as Source,

Here if i know remaining values to represents to what combination of source, then it would be helpful.

sridhar_sigired
Creator
Creator
Author

Wow, it seams you are right. Thanks peter.

I think i will get like this ... Thanks alot.

   

SOURCERepresentation
100S2
110A+S1+2
1000R3
1010A+R1+3
1100S+R2+3
1110A+S+R1+2+3
10000AA4
10010A+AA1+4
100100S+SS2+5
100110A+S+SS1+2+5