2 Replies Latest reply on Jun 25, 2015 7:43 PM by dennis.garlick

    How to reference a column's value in a calculated field?

    dennis.garlick

      Hi,

       

      Say if you have 2 date fields, OrderDate and FulfillmentDate, and you want to do a line graph showing the number of open orders on a day-to-day basis. In other words, a record will only be counted if the OrderDate is less than or equal to the current date being plotted, and the FulfillmentDate is greater than or equal to the current date being plotted or is null.


      When I reference fields in calculated fields, the values of the individual record are being referenced, not a variable value that changes as a value changes in a line graph. I presume that there is an easy way to reference a value from the axes of a line graph??

        • 1. Re: How to reference a column's value in a calculated field?
          Tableau kumar

          Hi dennis.garlick,

           

          I think, the following calculation will help you.

           

          Toady() is equal to Current Date ---- (Today is 25 -Jun-2015 IST)

           

          1) Create a calculation like below.

          If datediff( 'day', [Order_Date], today())<=0 and datediff( 'day', [Order_Fullfillment_Date], today())>=0  then [Show required Measure] end

           

          2)  Drag the Order ID or Referencing of Order ID Column into Columns Shelf.

          3) Drag the Above calculated field, select the marks Type "Line"

           

           

          Best Regards

          Laxman Kumar

          • 2. Re: How to reference a column's value in a calculated field?
            dennis.garlick

            Thanks for the suggestions so far. I tried the Today statement, but that didn't work as it only references the current date - not the differing dates that are being plotted in the figure. Kettan's response might work, but is less than ideal from a performance standpoint. Thinking about it some more, an alternative approach would be to have a Date range on the x-axis, then do a count of the number of records where [Order_Date]<Date, and do a count of the number of records where [Fulfillment_Date]<Date. This will give us two lines. If we can then calculate a third line that represents the difference between lines 1 and 2, it should be want is required. Is it possible to reference the value of one line in determining the value of another line?