How to Use Row Rank Function in Kusto | Row Rank Function | Kusto Query Language Tutorial 2022

Topic: How to Use Row Rank Function in Kusto.

In this article, we are going to learn about row rank function in Kusto row rank function returns the current rows rank in a serialized row set the row index starts by default at one for the first row and it increments by one whenever the provided term is different than the previous rows term. Kusto Query Language is a powerful tool for exploring your data and discovering patterns, identifying anomalies and outliers, creating statistical modeling, etc.

 //row_rank()- Returns the current row's rank in a serialized row set. The row index starts by default at 1 for the first row,  
 // and is incremented by 1 whenever the provided Term is different than the previous row's Term.  
 //create Table and Insert Sample Data in Azure Data Explorer DB for Testing  
 .drop table TotalSale  
 .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  
 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  
 4,John,Rivers,Laptop,5,2400,2014-03-09,Jersey City,NJ,USA,North America  
 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  

 // Giving the rank to each Region   
 | order by Region  
 | extend Rank=row_rank(Region)  

 //let's try to play little more and include Country with it  
 // Giving the rank to each Region   
 | extend RegionCountry=strcat(Region,'',Country)  
 | order by Region,Country  
 | extend Rank=row_rank(RegionCountry)  

Video Demo: How to Use Row Rank Function in Kusto | Row Rank Function 

No comments:

Post a Comment