split string column value into multiple rows in kusto
Asked Answered
D

1

5

I have a string column which includes "," delimiter, I want to split this column into multiple rows.

Here's the table

|Token          |Shop|
|a              |P   |
|A10,A9a,C1a,F1 |R   |

Expected Output:

|Token          |Shop|
|a              |P   |
|A10            |R   |
|A9a            |R   |
|C1a            |R   |
|F1             |R   |

I tried below logic using mv-expand but it doesn't seem to work

datatable(Tokens:string, Shop:string)["a", "P", 
"A10,A9a,C1a,F1", "R" ]
| mv-expand Token =todynamic(Tokens) to typeof(string)
Debunk answered 24/6, 2021 at 16:39 Comment(0)
F
11

You can use split() before mv-expand:

datatable(Tokens:string, Shop:string)["a","P","A10,A9a,C1a,F1","R" ]
| mv-expand token = split(Tokens, ",") to typeof(string) 
Fey answered 24/6, 2021 at 16:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.