Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
manran
New Member

Convert varbinary(4) to ip address

I have a column in a sql database with a varbinary(4) datatype.  I would like to display that column as ip addresses since that's what they represent.  In sql management studio the values appear as a hexadecimal value like: 0x7f000001.  However, power bi doesn't show the column in the data section.

 

I tried adding a new column using Binary.ToText([columnName]), but I ended up with values that didn't make sense to me.  Values like:  CgTHAA== 

 

Can someone help me understand what power bi is showing me, or point me in a better direction?

1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

I think Binary.ToList is your friend here.

Sample query 1:

 

let
    bin = Binary.From("7f000001", BinaryEncoding.Hex),
    bin_2_list = Binary.ToList(bin),
    num_2_text = List.Transform(bin_2_list, Number.ToText),
    list_2_ip = Text.Combine(num_2_text, ".")
in
    list_2_ip

 

 

Sample query 2:

 

let
    Source = Table.FromColumns({{"798f7a55","849c8574","8fa99093","9ab69bb2","a5c3a6d1","b0d0b1f0","bbddbd0f","c6eac82e"}}, {"IP"}),
    BinaryFormat = Table.TransformColumns(Source,{{"IP", each Binary.FromText(_, BinaryEncoding.Hex), type binary}}),
    IPs = Table.TransformColumns(BinaryFormat, {{"IP", each Text.Combine(List.Transform(Binary.ToList(_), Number.ToText), "."), type text}})
in
    IPs

 

You can add a new custom column by pasting this into the box:

Text.Combine(List.Transform(Binary.ToList([IP]), Number.ToText), ".")

AlexisOlson_0-1698690600745.png

 

 

View solution in original post

2 REPLIES 2
manran
New Member

wow, this worked great!  thanks for the help!

AlexisOlson
Super User
Super User

I think Binary.ToList is your friend here.

Sample query 1:

 

let
    bin = Binary.From("7f000001", BinaryEncoding.Hex),
    bin_2_list = Binary.ToList(bin),
    num_2_text = List.Transform(bin_2_list, Number.ToText),
    list_2_ip = Text.Combine(num_2_text, ".")
in
    list_2_ip

 

 

Sample query 2:

 

let
    Source = Table.FromColumns({{"798f7a55","849c8574","8fa99093","9ab69bb2","a5c3a6d1","b0d0b1f0","bbddbd0f","c6eac82e"}}, {"IP"}),
    BinaryFormat = Table.TransformColumns(Source,{{"IP", each Binary.FromText(_, BinaryEncoding.Hex), type binary}}),
    IPs = Table.TransformColumns(BinaryFormat, {{"IP", each Text.Combine(List.Transform(Binary.ToList(_), Number.ToText), "."), type text}})
in
    IPs

 

You can add a new custom column by pasting this into the box:

Text.Combine(List.Transform(Binary.ToList([IP]), Number.ToText), ".")

AlexisOlson_0-1698690600745.png

 

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.