5 Replies Latest reply on Mar 7, 2017 7:54 AM by Michael Hesser

# Complex (imaginary) numbers

Hi,

I work in an engineering environment and am starting to use Tableau (10.1) to try and tease out insights from our masses of measurement data.  The thing is most of this data in in complex form so comes in as Real & Imagninary components.  My question is can Tableau handle complex numbers natively or do I need to create calculated values if I want to look at the magnitude of the values and then another function to calculate the magnitude of the average of a complex number, which is the sqrt(average of the real parts ^2 + average of imaginary parts^2).

I'm new to Tableau so any assistance would be very welcome.

Thanks

Martin.

• ###### 1. Re: Complex (imaginary) numbers

Hi Martin

I think Tableau can do the calc as long as the complexity of the formula is below level.

sqrt(average of the real parts ^2 + average of imaginary parts^2).

But that really depends on your data structure.

If you attach packaged workbook, community members will easily help for more detailed solution.

Thanks,

Shin

• ###### 2. Re: Complex (imaginary) numbers

Ideally I'd like to know if Tableau can handle a complex number datatype natively i.e.  (X+Yi) as a single entity rather than as two individual numbers for the real and imaginary parts.

• ###### 3. Re: Complex (imaginary) numbers

Hi Martin;

I'm less convinced than Shin regarding this calculation:

sqrt(average of the real parts ^2 + average of imaginary parts^2)

This is because if your average of imaginary parts > average of real parts, you'll be trying to compute the square root of a negative number (i squared is -1) and get an error.

I think you can avoid this situation by using a simple IF clause first:

Create a calc adding the two

REAL PLUS IMAGINARY SQUARED

(average of the real parts ^2 + average of imaginary parts^2)

Now use an IF statement in a second calc:

SQUAREROOTER

IF [REAL PLUS IMAGINARY SQUARED] >= 0 then STR((SQRT([REAL PLUS IMAGINARY SQUARED]))

ELSEIF STR((SQRT(-[REAL PLUS IMAGINARY SQUARED]))+"i"

END

Here I'm adding "i" to any imaginary result... I'm also converting them as STRINGS.

If you know your imaginary values will always be less than your real values, you;ll be OKAY.

--Michael

• ###### 4. Re: Complex (imaginary) numbers

Michael,

It is only the component of imaginary part that is squared and summed, not the "i" itself.  For example the average of 2+5i & 4+3i is (2+4)/2 + (5+3)/2i  = 3+4i and its magnitude would be sqrt(3^2+4^2) = 5

If you type the following in to Excel you will see an example of a complex number data type that can be operated on as an entity - "=complex(3,4)", although even Excel doesn't manage to conduct calculations on complex numbers.

• ###### 5. Re: Complex (imaginary) numbers

Thank you-- I was mistaken

...and I learned something I never knew about Excel!