Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading