Kusto Query strcat How to Concatenate Columns in Kusto | Kusto Query Language Tutorial (KQL)

Topic: Kusto Query strcat How to Concatenate Columns in Kusto Query Language


In this article, we are going to learn how to concatenate columns in Kusto Query language or some value that we need to concatenate, Kusto Query Language is a powerful tool to explore your data and discover patterns, identify anomalies and outliers, create statistical modeling, and more. The query uses schema entities that are organized in a hierarchy similar to SQL's: databases, tables, and columns.

 ///strcat : Concatenates between 1 and 64 arguments. If the arguments aren't of string type, they'll be forcibly converted to a string.  
   
 .clear table TotalSale data   
 .create table TotalSale (  
   id: int   
   ,SalePersonFName: string  
   ,SalePersonLName : string  
   ,ProductName : string  
   ,ItemsSold : int  
   ,SoldPrice :real  
   ,SoldDate: date  
   ,City : string  
   ,State : string  
   ,Country : string  
   ,Region : string  
   )  
        
      //Insert data  
       .ingest inline into table TotalSale <|  
 11,Tamara,Tony,Cell Phone,2,1200,2015-03-03,Frankfurt,Hesse,Germany,Europe  
 11,Tamara,Tony,Cell Phone,2,1200,2015-03-03,Frankfurt,Hesse,Germany,Europe  
 9,Petra,Henry,TV,10,5000,2015-04-08,Paris,Île-de-France,France,Europe  
 3,Christy,Ladson,TV,3,1600,2015-04-02,High Point,NC,USA,North America  
 7,Chirag,Patel,Cell Phone,5,1500,2015-06-23,AhmadAbad,Gujrat,India,Asia  
 2,M,Raza,Cell Phone,2,800,2015-07-15,Charlotte,NC,USA,North America  
 5,Najaf,Ali,Computer,1,300,2015-06-20,Karachi,Sindh,Pakistan,Asia  
 6,Sukhjeet,Singh,TV,2,900,2015-06-21,ChandiGar,Punjab,India,Asia  
 4,John,Rivers,Laptop,5,2400,2014-03-09,Jersey City,NJ,USA,North America  
 8,Aleena,Aman,Laptop,2,800,2015-05-25,Lahore,Punjab,Pakistan,Asia  
 10,Rita,Roger,Laptop,7,2100,2015-04-11,Paris,Île-de-France,France,Europe  
 1,Aamir,Shahzad,TV,1,700,2015-07-15,Charlotte,NC,USA,North America  
 12,aamir,shahzad,TV,1,7000,2015-07-15,Charlotte,NC,USA,North America  
 id=Null,bisma,Roger,Laptop,7,2100,2015-04-11,Paris,Île-de-France,France,Europe  
   
 ///strcat : Concatenates between 1 and 64 arguments. If the arguments aren't of string type, they'll be forcibly converted to a string.  
   
 //Let's create a table Customer  
 //.drop table Customer  
 .create table Customer (CustomerId: long, FName: string,LName:string )   
  .ingest inline into table Customer <|  
 1,Aamir,Shahzad  
 2,Raza,Ali  
 3,Lisa,River  
 4,steve,Ladson  
 5,Robert,Jr  
   
 //Print and concate multiple values  
 print strcat("Aamir","  ","Shahzad",   "Age", 43) // Notice 43 is added but space is ignored  
   
 print strcat("Aamir"," ","Shahzad"," ","Age ", 43,' Does single quotes work') // yes you can add string in single quotes  
   
 print strcat(Aamir, ' ' , Shahzad) // Can you add string values without quotes?  
   
 print strcat(6, ' ' , 4) // Can you add string values without quotes?  
   
 print strcat('"Aamir"', ' ' , 'Shahzad') // How to Add double quotes in string concatenation  
   
 print strcat('Aamir','Fraction: ',45/2.0,' ','WholeNumber:' ,45,'  decimals' ,56.8888) // What will happen to decimical and fractions  
   
   
 //Use strcat for table columns to generate new columns  
 TotalSale  
 | project id,SalePersonFName,SalePersonLName,FullName=strcat(SalePersonFName,' ',SalePersonLName)  
   
   

Video Demo: Kusto Query strcat How to Concatenate Columns in Kusto | Kusto Query Language Tutorial (KQL)

1 comment: