Calculated Column with simple math for price comparisons

Hi all,
I want to calculate a price difference from today's price versus the price of 5 days ago.
Please help me with a best practice for that. Is the use of calculated column in a calculation view the right approach? How can the price field of 5 days ago be addressed? Ideally 5 should be a constant which should be able to be changed to 6 or 7 for further simulations.
Thanks for any help.
Guenther

Hi Patter ,
For the above requirement we don't need a calculation view to be created. Check the code below, I am re creating the scenario with an INNER JOIN.
  CREATE COLUMN TABLE "METALS_ONE_GEN"."TEST_TAB" (ID INTEGER,DATES DATE,PRICE INTEGER);
  INSERT INTO "METALS_ONE_GEN"."TEST_TAB" VALUES ( 1 , '2014-03-10',50);
    INSERT INTO "METALS_ONE_GEN"."TEST_TAB" VALUES ( 1 , '2014-03-15',50);
    INSERT INTO "METALS_ONE_GEN"."TEST_TAB" VALUES ( 1 , '2014-03-25',100);
    INSERT INTO "METALS_ONE_GEN"."TEST_TAB" VALUES ( 1 , '2014-03-20',80);
    INSERT INTO "METALS_ONE_GEN"."TEST_TAB" VALUES ( 1 , '2014-03-30',75);
    INSERT INTO "METALS_ONE_GEN"."TEST_TAB" VALUES ( 1 , '2014-04-04',150);
    INSERT INTO "METALS_ONE_GEN"."TEST_TAB" VALUES ( 1 , '2014-04-9',450);
select A.DATES,
       A.PRICE,
      ( B.PRICE - A.PRICE )
       from "METALS_ONE_GEN"."TEST_TAB" A
       INNER JOIN "METALS_ONE_GEN"."TEST_TAB" B
       ON
    B.DATES = ADD_DAYS(A."DATES",5) ;
Looks like, the JOIN operation is more optimized than the Calculation view in this case . Depends on the data , JOIN type may very .
Sreehari
Message was edited by: Sreehari V Pillai

Similar Messages

  • Standard Layout &Tcode for Price comparison Sheet

    Can i get Standard Layout &Tcode for Price comparison Sheet and also return delivery note(122).....

    Check with Transactions :
    Display Condition record report - V/I6
    Pricing Report - V/LD
    Create Net Price List - V_NL
    Deliveries-Due list - VL04
    Outbound Delivery Monitor - VL06o
    Incomplete delivery - V_UC</b>
    Customer Returns-Analysis - MC+A
    Thanks
    Seshu

  • Calculated Column with Null date end result needs to be text.

    Good Morning,
    I am using SharePoint 2010 and am trying to create a calculated column converting a date/time column to to show just a month and day.  Calculation is
    =TEXT([Anniversary],"m/d")
    This is to enable sorting on the month.  And this works fine except when there is no date entered in the "Anniversary" column.
    I have tried to modify the formula in this column to no avail.  http://social.technet.microsoft.com/Forums/sharepoint/en-US/0c9d5ae1-132a-4e02-8a91-c54708919d9a/show-calculated-date-column-as-null-when-there-is-no-date?forum=sharepointgenerallegacy
    I do not have access to modifying the code so have to work strictly OOB.  Any help would be greatly appreciated.

    I would think you could add an IF statement to verify if the text is null. So...
    =IF(ISNULL(TEXT(Anniversary, "m/d")), What we do when null, TEXT(Anniversary,"m/d"))
    Andy Wessendorf SharePoint Developer II | Rackspace [email protected]

  • Help with Simple Applescript for Midipipe

    Hey all, I'm in desperate need of help with some Applescript for use in a program called Midipipe:
    http://web.mac.com/nicowald/SubtleSoft/MidiPipe.html
    I simply require an Applescript for Midipipe that filters out all OFF notes except for the most recently pressed key, or most recently pressed ON note. So for example, when multiple keys have been pressed, only the most recently pressed key will send an OFF note. I hope that is clear enough, i've had some major issues trying to get this work and my last hope is to hit the forums and find some help .. I've posted on some of the audio forums and i'm hoping someone here knows how to code this.
    Thanks so much!! .. Its for an upcomming show next week so i'm hoping someone can get me in the right direction to solving this.
    -Jes

    I try to help, but you'll need to apply your brain cells to get it working with what I've already explained (three times with what I offer below).  Try something like the following (I am renaming your buttons to ch1,ch2,ch3,ch4,ch5,ch6 so that the same functions can be shared by all buttons...
    // this assigns listeners to all 6 buttons
    for(var i:uint=1; i<7; i++){
              this["ch"+String(i)].addEventListener(MouseEvent.CLICK, fl_ClickToSeekToCuePoint);
    // this processes any one of the 6 btns when they are clicked
    function fl_ClickToSeekToCuePoint_1(event:MouseEvent):void
        var btn = event.currentTarget;
        var cuePointInstance:Object = vid.findCuePoint(btn.name);
        vid.seek(cuePointInstance.time);
       resetButtons();    // this makes all buttons go back to normal
        btn.upState = btn.overState; // this makes the clicked button change states
    function resetButtons():void {
         for(var i:uint=1; i<7; i++){
              this["ch"+String(i)].upState =  this["ch"+String(i)].hitTestState;
    For this to work, your buttons need to have the same artwork in the hit frame as they do in the up frame.

  • Eval formula node vi cannot work with simple math functions

    Hi I have problem using eval formula node.
    And it produces error.
    The formula is AI0=AI0-AI6; AI1=AI1-AI6; AI2=AI2-AI6; AI3=AI3-AI6; AI4=AI4-AI6; AI5=AI5-AI6;
    Pls see the attached. I am using LV 7.1
    Pls help. Will be grateful for your help
    Clement
    Solved!
    Go to Solution.
    Attachments:
    eval_formula_test.vi ‏29 KB

    Yes, the problem are your variable names.
    Can you give us a bit of background why you want to do such a complicated and inefficient method for such a simple operation. The same could be done trivally with exactly three primitives (index array, array subset, subtract) and no purple at all.
    LabVIEW Champion . Do more with less code and in less time .

  • Lookup column in calculated column formula

    I have a Lookup column(Discountfirst) which has Number.
    I also have another Calculated column(Finaldate) with Resulttype DateTime.
    One more column(DateofReceipt) in Date.
    My Calculated column formula looks like this
    =(DateofReceipt)+(Discountfirst).
    I get an error
    "One or more column references are not allowed, because the columns are defined as a data type that is not supported in formulas".
    I googled and came to know I can't use Lookup Column in Calculated field.
    Any suggestion how can do this ?

    This can't be done using calculated columns because calculated columns can only be used for columns on the same list.
    Using SharePoint Designer Workflows you can just use Create List Item and Update List Item actions so that whenever a user adds a value the item will be added in another list's column which contains the previous amounts already.
    http://stackoverflow.com/questions/16295567/how-to-create-calculated-column-with-data-from-another-list
    https://social.msdn.microsoft.com/forums/sharepoint/en-US/01989169-eac7-4f28-809d-6e5af400fb03/lookup-column-to-calculated-field-showing-string-at-beginning
    Please 'propose as answer' if it helped you, also 'vote helpful' if you like this reply.

  • Last year sales calculation in calculated column

    Hi everybody!
    Please help me to solve issue with last year sales calculation in calculated column. I have 'Fact' table with sales for every period in it and related table 'Time' with 1, 2, 3 'PeriodID' column for string MAT 2011, MAT 2012, MAT 2013.
    I know the solution for measure:
    =CALCULATE ( SUM(Fact[Sales]); FILTER (ALL ('Time'); 'Time'[PeriodID] = MAX(Time[PeriodID]) - 1))
    But for the purpose of my analysis I need to make a calculated column. What I want to see looks like this table:
    Product
    Period
    Sales
    SalesLY
    A
    MAT 2013
    17
    10
    B
    MAT 2013
    20
    23
    C
    MAT 2013
    45
    33
    D
    MAT 2013
    13
    16
    A
    MAT 2012
    10
    8
    B
    MAT 2012
    23
    31
    C
    MAT 2012
    33
    5
    D
    MAT 2012
    16
    22
    A
    MAT 2011
    8
    0
    B
    MAT 2011
    31
    0
    C
    MAT 2011
    5
    0
    D
    MAT 2011
    22
    0

    Thanks for the idea!
    It's an option. I slightly modified expression to make it more generic:
    =CALCULATE
          SUM (Fact[Sales]);
          FILTER (
                        Fact; Fact[Product] = EARLIER (Fact[Product]) && Fact[PeriodID] = (EARLIER(Fact[PeriodID]) -1)
    Where Fact[PeriodID] is calculated column with '=RELATED (Time[PeriodID])' formula. To my opinion this is more universal approach.
    But it has the cons. EARLIER is memory demanded function. In case of 32-bit OS or numerous nested EARLIER error might occur.
    Is there any alternative solution?

  • I need create a column with level key...

    I need create a column with level key for city column in the location dimension, the same thing for village, ect.

    Hi Dapego,
    According to your description, you want to add an extra column with level key for city, and then add this column to location dimension as an attribute, right?
    In this case, you can define named calculation on the datasource view. Named calculations are Virtual columns that can be added on tables in Data Source View(DSV). This named calculation acts as a Column in your table and this column won't be reflected in
    your database.
    http://www.codeproject.com/Tips/660919/Introduction-to-Named-Calculations-in-SQL-Server-A
    http://msdn.microsoft.com/en-us/library/ms174859.aspx
    If I have anything misunderstanding, please point it out.
    Regards,
    Charlie Liao
    TechNet Community Support

  • Workflow::: Price Comparison

    Dear All,
    My clients requirement is that the SCM Manager should approve the Price Comparison before further action can take place. Can I do this through workflow??
    If there is any other possibility for it please let me know.
    Regards,
    Usman Nazir

    >
    Mani SAP wrote:
    > Dear All,
    >
    > My clients requirement is that the SCM Manager should approve the Price Comparison before further action can take place. Can I do this through workflow??
    >
    > If there is any other possibility for it please let me know.
    >
    > Regards,
    >
    > Usman Nazir
    Why you want workflow for simple transactions. I havent heard of any workflow for price comparison. Tell your SCM Manager to access the transaction and see the comparison and I guess if he is authorized to approve the follow on documents, we can get a check enabled, through ABAP thats once this check is enabled, follow on documents can be made and this authorization should be given to SCM Manager only.

  • Calculated column doesn't expand the items in list view

    Dear All,
              I have a calculated column
    Week with formula, =INT((DAY([Start Time])+6)/7) 
    in one of my lists. I'm displaying a view of this list in a SharePoint page, group by column Year and column
    Week. But when the page is loaded with items, I'm only able to expand the list view up to
    Year column level. When I click on Week section it doesn't show / expand the items under it.
    Further more when I use a different calculated column with a function like (=TEXT(Date,"yyyy")) I don't get above error.
    Any Idea?
    Thanks,
    Dilip

    Hi Dilip,
    According to your description, an issue occurs when you try to expand the subgroups in a list contains Calculated column.
    It is an known issue in SharePoint 2013, there are some workarounds I can provide as below:
    As the first workaround, you can set the groupings to expanded by default, though it would make the grouping collapsed by default, then the grouping would function
    normal.
    As the second workaround, you can create a SharePoint Designer Workflow and add a “Do Calculation” action to calculate the value you needed. Then add a “Update List
    Item” action to add the value to a “Single line of text” column. We will use the “Single line of text” column in the grouping instead of the Calculated column.
    As the third workaround, you can install the latest update of SharePoint to fix the issue for new Document Libraries. For the existing libraries, after the installing
    the update, you can use PowerShell to make an update to each item in the library, it will make the old items get normal in the grouping.
    About how to update list items in a list/library using PowerShell, a demo as below for your reference:
    $web = Get-SPWeb http://YourServer/
    $list = $web.Lists["list name"]
    foreach ($item in $list.Items)
    $item.SystemUpdate();
    Best regards
    Patrick Liang
    TechNet Community Support

  • CASE statement in Calculated column

    Hi Frzz,
    I have below requirement in Calculated column with CASE statement. Could some one help me how to achieve this with case statement.
    String  =   0Hello
                    01Hello
                    012Hello
                    0123Hello
    If  1st Character of the string is '0' then  -  0Hello
        1st 2 characters of the String is '01'  -   22Hello
        1st 3 characters of the String is '01'  -   333Hello
        1st 4 characters of the String is '01'  -  4444Hello
    Thank you.
    Best Regards,
    Krishna.

    Hi Krishna ,
    Using IF and MATCH to do that: ( I took one of the conditions you specified )
    IF(match("STRING1",'??0??'),'333Hello',"STRING1")
    Output:
    Regards,
    Krishna Tangudu

  • Manged Property based on calculated column

    Hi,
    I set a refiner based on a managed property.
    the managed property is mapped to the crawled property which is based on a document library calculated column with a formula:
    ="In Process" .
    In refinement panel i see
    string;#In Process
    instead of just display:
    In Process
    why is it so?
    keren tsur

    Hi keren,
    According to your description, my understanding is that you want to know why the value showed as “string;#In Process” of calculated column in Refinement Panel.
    Per my knowledge, it may be due to how the calculated column stores the value.
    Please take a look at the article below, from which we can know that the calculated column values show with string;# as the prefix in the lookup column:
    http://sympmarc.com/2009/10/09/sharepoint-lookup-column-based-on-a-calculated-column-woes/
    As its value has string;# as the prefix in calculated column, so the value shows in the Refinement Panel is string;#In Progress.
    Best regards.
    Thanks
    Victoria Xia
    TechNet Community Support

  • Calculated Columns

    Hi Folks,
    If I've got this in the wrong forum, I apologize.  But, I couldn't find another that seemed more appropriate.
    I've got a site in SP 2007, but do not have access to either designer, or Visual Studio.  
    I'm looking to create a column in a task list that will insert the current date upon the entry of 'completed'.  I'm looking to be able to track the date that a given task was completed.
    Can anyone advise how this can be done?

    Try create calculated column with formula: =IF([% Complete]>=1,[Modified],"")
    [custom.development]

  • Calculated Column using IF statement with DATEIF formula

    I have a dated column that includes a date when a position is vacated otherwise the field is blank if the position is still filled. I want a calculated column to return the number of days the position has been vancant from the date that is listed to today.
    So the following was entered & works.....
    =DATEDIF([Vacancy Date],Today,"d")
    The delima is that it is also returning a value when there is no date in the dated column but it returns a funky number 42,069. What I want it to return when the dated column is blank is blank or zero would work too. I don't know how to incorporate that
    into this formula.

    You are correct it no longer reads that column as Today.... So is there anyway to make this a calculated column for my purposes?
    I'm going to use SharePoint list for a Position Pool & managing positions within a large department. What I'm attempting to do with this column is have a current count of the number of days since a position has been vacant. Our system that I pull the
    position data from will give me the vacancy date for those positions & where the position is filled the date field will be blank. So I'm wanting this column to return a 0 when the position is listed as filled & the number of days vacant based on the
    vacancy date column I have. Is there any way to make this work in SharePoint? Obviously I can make that work in Excel however my task was to load raw data into SharePoint & have SharePoint do the work if possible with little to no human intervention prior
    to loading to SharePoint.
    Thank you,
    MMHagman

  • Need help with a calculated column - is there any way to reference a value in the current row?

    Hey guys,
    I'm a bit of a DAX newbie, and I'm running into a block. I'm creating a Power View report about IT tickets. We are going to be creating a cube to automate the data soon, I'm currently working with a flat Excel Data Table of data to demonstrate the Power
    View reporting capabilities to the team. I need the default display to show the top 4-5 items basked on the Ticket Count. The three applicable columns I'm using are the TicketID, the ContactReason, and the AssetCategory - all three are
    text. One slide will show the top five Contact Reasons by Ticket Count, and the other will show the top five Categories by Ticket Count. The users will see this default view, but will be able to change it to see differently ranked items or can clear the
    ranking slicer altogether.
    What I've accomplished so far is to create the Calculated Field [Ticket Count] = COUNTA(Table1[TicketID])
    And 2 other calculated fields:
    [Contact Rank] = RANKX(ALL(Table1[ContactReason]),[Ticket Count],,,DENSE)
    [Asset Rank] = RANKX(ALL(Table1[AssetCategory]),[Ticket Count],,,DENSE)
    If I were creating a Pivot Table, this would be great. These fields calculate everything the right way. The problem is, I need to have a Rank slicer on each slide and the calculation by itself contains no data - with no data, there's nothing to slice. I
    realized I need to actually have columns of data so I can create a slicer. I need each row of the table to show the same [Contact Rank] for every instance of a particular ContactReason (and the same for the [Asset Rank] and AssetCategory).
    The RANKX formulas pasted into the Calculated Column section only show a value of 1 - with no Pivot table summarizing the fields, it's counting each row's ticket once, giving every line the tied Rank of #1.
    I've solved the problem in Excel by creating 2 Pivot Tables on a separate sheet that have the data field and the calculated field for ContactRason and AssetCategory. Then on my Excel Data Table, I've added two columns that do a VLOOKUP and pull over a the
    Calculated Rank from each Pivot Table that match the ContactReason and AssetCategory fields. This works on the flat Excel Data Table now, but will not be a solutions when we start pulling the data from the cube (and there is no flat table).
    What I think I need is an Expression for the RANKX formula that can give me, for each row, the count of all of the times a ContactReason shows up in an entire column. There's only about 100,000 lines of data and each ContactReason or AssetCategory
    may show up several thousand times. But if I can get the expression to return that count, then the RANKX formula should work in the Column. If it wasn't a DAX formula, I'd use a COUNTIF and say 'Count the entire ContactReason column anytime it's equal to the
    ContactReason on THIS row', but in DAX I don't know how to reference a single value in a row. I've tried the CALCULATE() formula, but it seems like the filter needs a specific value, and doesn't work on a dynamic "cell" value.
    Any help would be greatly appreciated! (I hope it all makes sense!)

    If I've understood you correctly then the ALLEXCEPT function may be what you're after and it could be applied in a similar way to the following...
    =
    RANKX(
    ALL(Table1),
    CALCULATE(
    COUNTROWS(table1),
    ALLEXCEPT(Table1, Table1[ContactReason])
    DENSE
    If this has missed the mark, would it be possible to clarify the requirement further?
    Regards,
    Michael Amadi
    Please use the 'Mark as answer' link to mark a post that answers your question. If you find a reply helpful, please remember to vote it as helpful :)
    Website: http://www.nimblelearn.com
    Blog: http://www.nimblelearn.com/blog
    Twitter: @nimblelearn

Maybe you are looking for

  • Set default role for Account in SAP CRM 7.0

    We are using SAP CRM 7.0 When an end user creates a new account there is a section called "Role" sub assignment block with entries like "Competitor", "Account", Contact Person, etc. I want by default when you create an account that the role Account i

  • Performance problems processing big volumes using ABAP-proxy framework

    Hi    We have a custom application ABAP program running on a ECC50 ( WAS640 ) box - that reads change pointer information based on a Z* msg type and generates proxy messages - sending them to XI. Now in every run, this ABAP program pushes out 5000 to

  • Pacman is horribly slow to sync with Community.

    I've really had this problem ever since I started using Arch and I figured I was just screwing something up so I'm here to find out what. So of course I always run rankmirrors after a new install and currently my mirrors are. Server = http://archlinu

  • ORDERS05 IDoc to cXML SOAP - SOAP failing (Ariba call)

    I am performing the following scenario: I am sending an ORDERS05 IDoc from R/3 4.6 to XI.  XI then maps the IDoc into cXML.  I am then attempting to send the cXML via the SOAP adapter to Ariba via HTTP. Everything works except the adapter fails when

  • New camera, can't edit RAW, CS5.1

    Camera: Canon G16 Computer: Macbook pro 2012 OS: 10.9.1 Adobe: CS5.1 Just recently bought G16. Now can no longer open files in Camera Raw. I get the error "The photoshop camera raw plug-in did not recognize the format of one or more files. If these f