Oracle Analytics Cloud and Server

Welcome to the Oracle Analytics Community: Please complete your User Profile and upload your Profile Picture

function absolute in calculated item

Received Response
121
Views
19
Comments
3689512
3689512 Rank 2 - Community Beginner

Im trying to calculated the percentage difference between two columns using a calculated item ($2-$1)/$2 but it fails when both values are less than 0. Is there a way to apply absolute function? Documentation says yes but havent managed to make it work

«1

Answers

  • SriniVEERAVALLI
    SriniVEERAVALLI Rank 6 - Analytics Lead

    Try like below

    ( ($2-$1)*1.00)/$2

  • 3689512 wrote:... but it fails when both values are less than 0.

    Can you define "fails" ?

    Do you have an error? Do you have a wrong result? What kind of result? (post an example or screenshot maybe?)

  • 3689512
    3689512 Rank 2 - Community Beginner

    didnt work gives the same result

  • [Deleted User]
    [Deleted User] Rank 2 - Community Beginner

    Yeah because that's not how "absolute" works mathematically... "times 1.00" is a trick to prevent integer divisions and has nothing to do with absolute numbers.

  • 3689512
    3689512 Rank 2 - Community Beginner

    the sign is wrong when both numbers are negative  . E.g: -2-(-4)/-4. where -2>-4 so it's 50% higher not -50%

  • 3689512
    3689512 Rank 2 - Community Beginner

    the sign is wrong when both numbers are negative  . E.g: -2-(-4)/-4. where -2>-4 so it's 50% higher not -50%

  • [Deleted User]
    [Deleted User] Rank 2 - Community Beginner

    Is there a specific reason why you use $ notation and not a real formula where you can use ABS?

  • 3689512
    3689512 Rank 2 - Community Beginner

    what do you mean with @ notation? It's a calculated item not column. is there another way to do math operations in a calculated item?pastedImage_0.png

  • [Deleted User]
    [Deleted User] Rank 2 - Community Beginner

    I know it's a calc item. My point is: actual formulas are far more precise and with calc items it's easy to have something in $1 and $2 which isn't what you expect  (influenced by prompts, filters, selections,........)

  • 3689512
    3689512 Rank 2 - Community Beginner

    I dont know how to get the result i want using calculated column. My data is like this.

    pastedImage_0.png

    Where % Var is the calculated item. How can i create a new column with just the percentage difference between column Real and Plan