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

Create a function to calculate power of tens with a loop and reuse them in another query

I need a KQL function which calculates the power of tens (or maybe N), where I can pass the base and the exponent and get back the result.

I´m new in KQL, so I don´t know how exactly define the function and how to implement some sort of for-loop. Can someone help me out?

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 :

You could create a powerN function and use the range operator to loop over it, like this:

let powerN = (base: real, exponent: int) {
    exp(log(base) * exponent)
};
range x from 1 to 10 step 1
| project powerN(10, x)

See the Demo here.

Result:

enter image description here

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