Daily DAX : Day 342 RADIANS
Power BI DAX RADIANS Function
Description
The RADIANS
function in Power BI DAX converts an angle from degrees to radians. Many trigonometric calculations, such as those involving SIN
, COS
, or TAN
, require angles in radians rather than degrees.
Syntax
RADIANS(number)
- number: The angle in degrees (required).
Return Value
The angle converted to radians (numeric value).
Use Case
The RADIANS
function is useful in scenarios involving trigonometric calculations, such as:
- Calculating distances between geographic coordinates using the Haversine formula.
- Performing calculations in engineering or physics dashboards that involve angles.
- Creating visualizations that require trigonometric transformations.
Example
Suppose you have a column Degrees
with an angle value of 180. You want to convert it to radians for use in a SIN
calculation.
SineOfAngle = SIN(RADIANS(180))
Result: RADIANS(180)
returns approximately 3.14159 (π radians), and SIN(RADIANS(180))
returns 0, since the sine of π radians is 0.
Practical Example: Haversine Formula
To calculate the distance between two geographic points (latitude and longitude), you need angles in radians. For example:
Distance =
VAR Lat1 = RADIANS(Table[Latitude1])
VAR Lat2 = RADIANS(Table[Latitude2])
VAR Lon1 = RADIANS(Table[Longitude1])
VAR Lon2 = RADIANS(Table[Longitude2])
RETURN
6371 * ACOS(
COS(Lat1) * COS(Lat2) * COS(Lon2 - Lon1) + SIN(Lat1) * SIN(Lat2)
)
This calculates the distance in kilometers between two points on Earth, using RADIANS
to convert latitude and longitude from degrees to radians.
Notes
- The input
number
must be a numeric value representing degrees. - The function is often paired with trigonometric functions like
SIN
,COS
, orTAN
. - If the input is non-numeric, it will result in an error.
Comments
Post a Comment