Create calculations from calculated columns

(3 posts) (2 voices)

Tags:

  1. cayasanchez, Member

    Hi MyDBR Team:

    I'm trying to do some calculations over calculated columns but I got 0 as result. The column Profit is showing accurate values but the %Profit shows only zeros.

    Here is a sample of what I'm trying to do:

    select 'dbr.calc', 'Profit', '[Total_Rev]-[Cost]'; select 'dbr.calc', '%Profit', '[Profit]/[Profit.sum] * 100';

    select 'dbr.sum', 'Cost', 'Total_Rev', 'Profit';

    SELECT Device, Total_Rev, Cost, NULL as Profit, NULL as '%Profit' FROM Table group by Device

  2. myDBR Team, Key Master

    Yes, you have to do it bit longer way:

    select 'dbr.calc', '%Profit', '[Profit]/([Total_Rev.sum]-[Cost.sum]) * 100';

    Or, do the first calculation in SQL:

    select 'dbr.calc', '%Profit', '[Profit]/[Profit.sum] * 100';
    select 'dbr.sum', 'Cost', 'Total_Rev', 'Profit'; SELECT Device, Total_Rev, Cost, Total_Rev - Cost as Profit, NULL as '%Profit'
    FROM Table

    --
    myDBR Team

  3. cayasanchez, Member

    Thanks! Now it is working and showing the correct values


Reply

You must log in to post.