Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
realpixel
Creator
Creator

Convert HEX value to IP address

Hello,

On my chart, I have a column "SourceIP" with Hexadecimal value, like "0A5C0158", if I convert manualy this value to decimal I obtain 10.92.1.88 now I want to know if there are a possibility to convert all value in my chart from HEX to IP address, someone have an idea?

1 Solution

Accepted Solutions
sunny_talwar

You def. don't want to use static value in your chart, that was just an example. This is what you need:

=Num(Num#(Left(Num(Num#(SourceIP, '(HEX)'), '(BIN)'), Len(Num(Num#(SourceIP, '(HEX)'), '(BIN)')) - 24), '(BIN)'))&'.'&

Num(Num#(Mid(Num(Num#(SourceIP, '(HEX)'), '(BIN)'), Len(Num(Num#(SourceIP, '(HEX)'), '(BIN)')) - 23, 8), '(BIN)'))&'.'&

Num(Num#(Mid(Num(Num#(SourceIP, '(HEX)'), '(BIN)'), Len(Num(Num#(SourceIP, '(HEX)'), '(BIN)')) - 15, 8), '(BIN)'))&'.'&

Num(Num#(Right(Num(Num#(SourceIP, '(HEX)'), '(BIN)'), 8), '(BIN)'))

View solution in original post

10 Replies
sunny_talwar

May be this:

=Num(Num#(Left(Num(Num#('0A5C0158', '(HEX)'), '(BIN)'), Len(Num(Num#('0A5C0158', '(HEX)'), '(BIN)')) - 24), '(BIN)'))&'.'&

Num(Num#(Mid(Num(Num#('0A5C0158', '(HEX)'), '(BIN)'), Len(Num(Num#('0A5C0158', '(HEX)'), '(BIN)')) - 23, 8), '(BIN)'))&'.'&

Num(Num#(Mid(Num(Num#('0A5C0158', '(HEX)'), '(BIN)'), Len(Num(Num#('0A5C0158', '(HEX)'), '(BIN)')) - 15, 8), '(BIN)'))&'.'&

Num(Num#(Right(Num(Num#('0A5C0158', '(HEX)'), '(BIN)'), 8), '(BIN)'))


Capture.PNG

realpixel
Creator
Creator
Author

Hello,

Thank you for your reply but it's works only for value  '0A5C0158' but not for other value in my chart.

I have a column named "SourceIP" all value are in HEX and I want to convert there défirent value to IP addess.

sunny_talwar

Can you share few other values for where it isn't working?

realpixel
Creator
Creator
Author

For example the value 0A5C0A64 (10.92.10.100) have same IP (10.92.1.88) like the value '0A5C0158'

sunny_talwar

Not sure what the issue is. It seem to work for both the values for me:

Capture.PNG

sunny_talwar

Not sure where you are doing this, but replace all the red places with your new Hex Code:

=Num(Num#(Left(Num(Num#('0A5C0158', '(HEX)'), '(BIN)'), Len(Num(Num#('0A5C0158', '(HEX)'), '(BIN)')) - 24), '(BIN)'))&'.'&

Num(Num#(Mid(Num(Num#('0A5C0158', '(HEX)'), '(BIN)'), Len(Num(Num#('0A5C0158', '(HEX)'), '(BIN)')) - 23, 8), '(BIN)'))&'.'&

Num(Num#(Mid(Num(Num#('0A5C0158', '(HEX)'), '(BIN)'), Len(Num(Num#('0A5C0158', '(HEX)'), '(BIN)')) - 15, 8), '(BIN)'))&'.'&

Num(Num#(Right(Num(Num#('0A5C0158', '(HEX)'), '(BIN)'), 8), '(BIN)'))

realpixel
Creator
Creator
Author

Yes, If I replace '0A5C0158' by '0A5C0A64' it's works but all value in my chart have the same IP address '10.92.10.100'

Maybe the solution, it's to split the column "SourceIP" (AABBCCDD)

To have AA in new field like "HEXIP1"

BB in new field like "HEXIP2"

CC in new field like "HEXIP3"

DD in new field like "HEXIP4"

And after convert HEXIP1, HEXIP2, HEXIP3 and HEXIP4 from Hex to decimal to new other field as DECIP1, DECIP2, DECIP3, DECIP4

And to finish concatenate DECIP1+DECIP2+DECIP3+ECIP4 to have the final result

DECIP1.ECIP2.DECIP3.DCIP4

sunny_talwar

You def. don't want to use static value in your chart, that was just an example. This is what you need:

=Num(Num#(Left(Num(Num#(SourceIP, '(HEX)'), '(BIN)'), Len(Num(Num#(SourceIP, '(HEX)'), '(BIN)')) - 24), '(BIN)'))&'.'&

Num(Num#(Mid(Num(Num#(SourceIP, '(HEX)'), '(BIN)'), Len(Num(Num#(SourceIP, '(HEX)'), '(BIN)')) - 23, 8), '(BIN)'))&'.'&

Num(Num#(Mid(Num(Num#(SourceIP, '(HEX)'), '(BIN)'), Len(Num(Num#(SourceIP, '(HEX)'), '(BIN)')) - 15, 8), '(BIN)'))&'.'&

Num(Num#(Right(Num(Num#(SourceIP, '(HEX)'), '(BIN)'), 8), '(BIN)'))

realpixel
Creator
Creator
Author

Great, thank you very much, it works