Azure

Azure Knowledge Explorer – Carry out Calculation On A number of Values From Single Kusto Enter

Let’s think about a state of affairs, whereby the requirement is to search out out the share of a selected sort of values from a single enter set.

 

Beneath might be thought-about for instance of enter pattern knowledge and we have to discover out what proportion of dev releases and what  proportion of prod launched are current within the enter knowledge.

  1. let demoData = datatable(Setting: string, Characteristic:string)  
  2. [  
  3. “dev”“Feature1”,  
  4. “test”“Feature1”,  
  5. “prod”“Feature1”,  
  6. “Dev”“Feature2”,  
  7. “test”“Feature2”,  
  8. “dev”“Feature3”,  
  9. “test”“Feature3”,  
  10. “prod”“Feature3”  
  11. ];  

Strategy

 

As a way to obtain the answer, one has to undergo varied steps as talked about beneath,

 

Step 1

 

Get the entire variety of information from the set.

  1. let totalRecords = demoData
  2. rely 
  3. | challenge TotalRecords = Rely;  

Step 2

 

Get solely these information that are of sort ‘dev’

  1. let devRecords = demoData
  2. the place Setting =~ “dev” 
  3. rely 
  4. | challenge TotalDevRecords = Rely;  

Step 3

 

Get solely these information that are of sort ‘prod’

  1. let prodRecords = demoData
  2. the place Setting =~ “prod” 
  3. rely
  4. | challenge TotalProdRecords=Rely;  

To date we now have received all the person elements. The subsequent job is to mix all of the above talked about Three steps and generate a single outcome set and right here comes the problem.

 

Problem

 

As enter set is holding solely two columns, there is no such thing as a widespread subject in all of the above talked about three queries, and as there is no such thing as a commonality it’s considerably tough to deliver such a outcome set collectively to type a single outcome set.

 

Addressing the problem

 

Can’t we go forward and introduce some new column only for the sake of projection? Effectively, let’s see how that adjustments our above Three steps now,

 

Up to date Step 1

  1. let totalRecords = demoData  
  2. rely |lengthen CommonCol=“Dummy”   
  3. | challenge CommonCol, TotalRecords = Rely;  

Up to date Step 2

  1. let devRecords = demoData  
  2. the place Setting =~ “dev”   
  3. rely | lengthen CommonCol=“Dummy”   
  4. | challenge CommonCol, TotalDevRecords = Rely;  

Up to date Step 3

  1. let prodRecords = demoData  
  2. the place Setting =~ “prod”   
  3. rely|lengthen CommonCol=“Dummy”   
  4. | challenge CommonCol, TotalProdRecords = Rely;  

Now comes the ultimate step, whereby we have to deliver all of the above outcome set collectively to calculate the share.

 

Step 4

 

Combining the person outcomes to get a single outcome.

  1. totalRecords  
  2. be a part of (devRecords | be a part of prodRecords on CommonCol) on CommonCol  
  3. | lengthen DevRecords = (TotalDevRecords * 100)/TotalRecords  
  4. | lengthen ProdRecords = (TotalProdRecords * 100)/TotalRecords  
  5. | challenge DevRecords, ProdRecords;  

Full question 

  1. let totalRecords = demoData  
  2. rely   
  3. |lengthen CommonCol=“Dummy”   
  4. | challenge CommonCol, TotalRecords = Rely;  
  5. let devRecords = demoData  
  6. the place Setting =~ “dev”   
  7. rely   
  8. | lengthen CommonCol=“Dummy”   
  9. | challenge CommonCol, TotalDevRecords = Rely;  
  10. let prodRecords = demoData  
  11. the place Setting =~ “prod”   
  12. rely|lengthen CommonCol=“Dummy”   
  13. | challenge CommonCol, TotalProdRecords = Rely;  
  14. totalRecords  
  15. be a part of (devRecords   
  16. be a part of prodRecords on CommonCol) on CommonCol  
  17. | lengthen DevRecords = (TotalDevRecords * 100)/TotalRecords  
  18. | lengthen ProdRecords = (TotalProdRecords * 100)/TotalRecords  
  19. | challenge DevRecords, ProdRecords;  

Consequence 

 

On execution of the above steps, you’re going to get the specified output as proven beneath,

 

 

Hope you loved studying.

 

Comfortable kustoing.

Tags
Show More

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Close