Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

IP Address Comparison between a Range Connecting Two Tables

Hi,

 

I was wondering if anyone can help me:

 

I have Table1 which has a column full of IP addresses. 

 

I have Table2 which contains lots of different IP address ranges and what the location of these ranges belong to.

 

I want to take a value from table 1 and check what range it is in within table 2 and return that location.

 

Would you be able to help advise how to do this?

  • Anonymous , Use this power query code to convert all three ips into number , create new columns

     

    use correct column name in place Column1

     

    Number.FromText(Text.Combine( List.Transform( Text.Split([Column1],"."), each Text.PadStart(_,3,"0"))))

     

    One done do this DAX, new column in table 1

     

    maxx(filter(Table2, table1[IP_num] >= Table2[IP1_num] && table1[IP_num] <= Table2[IP2_num] ) , Table2[Location])

1 Reply

  • Anonymous , Use this power query code to convert all three ips into number , create new columns

     

    use correct column name in place Column1

     

    Number.FromText(Text.Combine( List.Transform( Text.Split([Column1],"."), each Text.PadStart(_,3,"0"))))

     

    One done do this DAX, new column in table 1

     

    maxx(filter(Table2, table1[IP_num] >= Table2[IP1_num] && table1[IP_num] <= Table2[IP2_num] ) , Table2[Location])