Greg_Deckler's avatar
Greg_Deckler
Community Champion
6 years ago

IMPOWER

In my recent quest to create or catalog as many DAX equivalents for Excel functions, was able to leverage COMPLEXIMAGINARY and IMREAL into IMPOWER.

 

IMPOWER = 
    VAR __Real1 = [IMREAL]
    VAR __i1 = [IMAGINARY]
    VAR __power = MAX('Table'[power])
    VAR __r = POWER(SQRT(POWER(__Real1,2) + POWER(__i1,2)),__power)
    VAR __theta = ATAN(__i1/__Real1)
    VAR __Real = __r * COS(__power * __theta)
    VAR __i = __r * SIN(__power * __theta)
    VAR __suffix = IF(MAX([suffix])="","i",MAX([suffix]))
RETURN
    SWITCH(TRUE(),
        __Real = 0 && __i = 1, __suffix,
        __Real = 0 && __i = -1, "-" & __suffix,
        __Real = 0, __i & __suffix,
        __i = 0, __Real & "",
        __i < 0 && __i = -1, __Real & "-" & __suffix,
        __i < 0, __Real & "-" & ABS(__i) & __suffix,
        __i = 1, __Real & "+" & __suffix,
        __Real & "+" & __i & __suffix
    )

 

I can't decide if this function is affirmational or pretentious...

 

Credit for the graphic goes to my son Rocket, who I have commissioned to create images for my Quick Measure Gallery entries. Proud dad moment! 🙂

 

 

No RepliesBe the first to reply