4 Replies Latest reply on Jun 15, 2018 4:27 AM by Jim Dehner

    Calculated field giving error.

    Amit M

      Hi All,


      I am facing an issue while creating one calculated field and would need expert advice on how to write the below calculation so that it would not give any error. The data which i am working on is confidential data so I couldn't share the workbook on forum but would answer all the questions if anything is not clear or i missed any detail.


      This is the condition which i am trying to write but it is giving me below error. Please refer the below screen shot for details of the fields and data type which i am using in this calculation.



        ELSEIF [BCG]=1 THEN DATE([Next Visit Date])



      Calculated field.PNG



      Thank you in advance.




        • 1. Re: Calculated field giving error.
          Simon Runc

          hi Amit,


          So the problem here is the BCG calculation, which is an Aggregate (MAX). So as an aggregate works over the level of detail of the Viz, Tableau can't combine row level (all the other parts of your calculation) with this aggregation, as it doesn't know what the MAX is of.


          If you let me know at what level the MAX is over? (eg. if it was patients, and they might have several entries, and you want to take the MAX over their entries) I can give you an LoD version, which gets returned at row level, so can be used in this calculation.

          1 of 1 people found this helpful
          • 2. Re: Calculated field giving error.
            Jim Dehner

            Good morning

            without seeing the data I can only guess which field it aggregated but you have something that you BCG, Next Visit Date, Or Date of Birth that is an aggregate - probably from a previous calculation - and remember - min(), Max() are also aggregates - you can wrap the other variables (the ones not aggregated in Attr(), Min() or max() whichever works best in your analysis




            If this posts assists in resolving the question, please mark it helpful or as the 'correct answer' if it resolves the question. This will help other users find the same answer/resolution.  Thank you.

            1 of 1 people found this helpful
            • 3. Re: Calculated field giving error.
              Amit M

              Hi Jim,


              Thank you for your explanation and quick response. Your example is similar to what i am trying to achieve using max function with BCG calculated field. Request you to please share the LoD version of BCG so that I would replace it with my current calculation of BCG and intern it would fix this calculation as well.


              I am newbie on tableau. Appreciated your help on this.




              • 4. Re: Calculated field giving error.
                Jim Dehner

                Good morning


                you will need to share more information -


                suggest you review the readings at

                Getting Started in the Forums