Atan2 Function From Power Fx Using Power Apps

Power Apps is a suite of apps, services, connectors, and data platforms that provide a rapid application development environment to build custom apps for your business needs. More Details https://docs.microsoft.com/en-us/powerapps/powerapps-overview.

Power Fx is the low-code language that will be used across the Microsoft Power Platform. It's a general-purpose, strong-typed, declarative, and functional programming language.

The Atan2 function returns the arctangent, or inverse tangent, of the specified x and y coordinates as arguments. The arctangent is the angle from the x-axis to a line that contains the origin (0, 0) and a point with coordinates (x, y). The angle is given in radians between -π and π, excluding -π. A positive result represents a counterclockwise angle from the x-axis; a negative result represents a clockwise angle. Atan2( a, b ) equals Atan( b/a ), except that a can equal 0 (zero) with the Atan2 function. The General syntax is Atan2(x,y).

Reading this article, you can learn how to perform the Atan2 function from Power Fx using Microsoft Power Apps. Also, you will be able to learn Button control, Label control, and text input control in the Power Apps environment.

Step 1. Open the URL https://powerapps.microsoft.com/en-us/ in the browser for Power apps.

Create an account with your Organisation Mail ID and log in after logging into your Power Apps account.

Organisation Mail ID

Step 2. First, Click Create (+ ) and Select the Canvas app from blank.

 Canvas app

Create

Next, give the app name as PADATan2 and format it as Tablet.

PADATan2

Step 3. To test the power function, First Rename the Screen name as SCRPAD.

Power function

Next, Insert a Label control and set the Name and Text property as LblTitle and Atan2 function in canvas App using PowerFx with Power apps.

Label control

Next, Insert a Label control and set the Name and Text property as LblXaxis and " Enter X-axis coordinate:"

 LblXaxis

Insert a TextInput control and set the Name property as TXTXaxis and Format property as Number.

TextInput control

Next, Insert a Label control and set the Name and Text property as LblYaxis and " Enter Y-axis coordinate:"

Text property

Insert a TextInput control and set the Name property as TXTYaxis and Format property as Number.

Format property

Insert a Button control and set the Name property as BtnCal and Text property as Calculate and set OnSelect action as UpdateContext({X:(TXTXaxis)}); UpdateContext({Y:(TXTYaxis)}); for testing the Atan2 function in Power Fx.

Button control

Insert Label control and set the Name property as LblRes and Text property as "The arctangent of the angle from the x-axis of the line that contains the origin (0,0) and the coordinate ( " & X.Text&","&Y.Text&" ), which is approximate "& Atan2(X.Text, Y.Text)& " degrees" for displaying Results.

LblRes and Text property

Insert a Button control and set the Name property as BtnClr, Text property as Clear, and OnSelect Property in Action as Reset(TXTXaxis); Reset(TXTYaxis); UpdateContext({LblRes:""}); for reset the Textboxes and Result.

OnSelect  Property

Finally, the form design looks like this.

Form design

Step 4. Now we can see the preview of your App in Power Apps Studio, and The output of the PADATan2 is,

Power Apps Studio

After clicking the Calculate Button, The Browser Display is,

Calculate Button

The Apple iPhone Display is,

Apple iPhone Display

The Tablet Display is,

Tablet Display

After clicking the Clear Button,

Clear Button

Summary

Now, you have successfully tested the Power Fx – Atan2 inverse function in the Power Apps Studio environment.


Similar Articles