Darien Pardinas
Darien Pardinas

Reputation: 6196

Kusto: How to transform a table to a table where columns and rows are defined by unique values of two columns?

Say I have a table like this:

Computer AppName AppVersion
C1 App1 1.0
C1 App2 2.0
C2 App1 3.0
C2 App2 4.0
C3 App1 5.0
C3 App2 6.0

I'd like to transform it into a table like this:

Computer App1 App2
C1 1.0 2.0
C2 3.0 4.0
C3 5.0 6.0

Is that possible in KQL?

Upvotes: 1

Views: 168

Answers (1)

David דודו Markovitz
David דודו Markovitz

Reputation: 44971

pivot plugin

datatable(Computer:string, AppName:string, AppVersion:string)
[
   ,"C1" ,"App1" ,"1.0"
   ,"C1" ,"App2" ,"2.0"
   ,"C2" ,"App1" ,"3.0"
   ,"C2" ,"App2" ,"4.0"
   ,"C3" ,"App1" ,"5.0"
   ,"C3" ,"App2" ,"6.0"
]
| evaluate pivot(AppName, take_any(AppVersion))
Computer App1 App2
C1 1.0 2.0
C2 3.0 4.0
C3 5.0 6.0

Fiddle

Upvotes: 1

Related Questions