Min and MinIf in Kusto Query | Azure Data Explorer | Kusto Query Language Tutorial (KQL)

Topic:  Min and MinIf  Functions in Kusto Query Language 

in this article, we are going to learn about two functions in Kusto Query Language one is min and otherone is the minif min function returns the minimum value across the group, and minif function returns the minimum value across the group for which predicates evaluate to true, 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.

 // min and minif - Returns the minimum value across the group for which Predicate evaluates to true.  
 //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  
 //Get the Max value across table  
 | summarize min(SoldPrice)  
 // get max value for each Region  
 | summarize min(SoldPrice) by Region  
 //using max by using Region by using maxif  
 | summarize minif(SoldPrice,Region=="Asia")  
 | summarize minif(SoldPrice,ItemsSold>3)  

Video Demo:  Min and MinIf in Kusto Query | Azure Data Explorer | Kusto Query Language Tutorial (KQL)

1 comment:

  1. I'm just a beginner, so tiny fishing Kusto Query Language is too hard for me.