Forum Discussion
How do I create a custom column that grabs the ip from a description?
I'm trying to make a simple dashboard to review our logs and was hoping I could create custom column that grabs IP addresses from the description but I am having a rough time when there is no IP or if its not in between two lines.
Is there a way for powerbi to look for #.#.#.# which is typically an IP address and display it in a column and not show anything if there isn't an IP #.#.#.# in the description?
Hi bashheadonwall ,
Use the following dax to create a new column:
Column = VAR test1 = MID ( 'Table'[Description], SEARCH ( ":", 'Table'[Description],, 0 ) + 1, 1 ) VAR test2 = SEARCH ( ",", 'Table'[Description], SEARCH ( ":", 'Table'[Description],, 0 ) + 1, 0 ) VAR test3 = IF ( test1 = "1" || test1 = "2" || test1 = "3" || test1 = "4" || test1 = "5" || test1 = "6" || test1 = "7" || test1 = "8" || test1 = "9" || test1 = "0", MID ( 'Table'[Description], SEARCH ( ":", 'Table'[Description],, 0 ) + 1, test2 - ( SEARCH ( ":", 'Table'[Description],, 0 ) + 1 ) ) ) RETURN test3return:
Did I answer your question? Mark my post as a solution!
Best RegardsLucien
2 Replies
- Ashish_Mathur
Super User
Hi,
Have you tried using the Column from Examples feature of the Query Editor?
- v-luwang-msft
Community Support
Hi bashheadonwall ,
Use the following dax to create a new column:
Column = VAR test1 = MID ( 'Table'[Description], SEARCH ( ":", 'Table'[Description],, 0 ) + 1, 1 ) VAR test2 = SEARCH ( ",", 'Table'[Description], SEARCH ( ":", 'Table'[Description],, 0 ) + 1, 0 ) VAR test3 = IF ( test1 = "1" || test1 = "2" || test1 = "3" || test1 = "4" || test1 = "5" || test1 = "6" || test1 = "7" || test1 = "8" || test1 = "9" || test1 = "0", MID ( 'Table'[Description], SEARCH ( ":", 'Table'[Description],, 0 ) + 1, test2 - ( SEARCH ( ":", 'Table'[Description],, 0 ) + 1 ) ) ) RETURN test3return:
Did I answer your question? Mark my post as a solution!
Best RegardsLucien