2 Replies Latest reply on Feb 3, 2017 9:54 AM by Sarah Ebreo

    Do calculation based on variables in two databases?

    yinqiu Zhu

      Hello there,

      I want to calculate the value of custs (which is in database Accounts_final_sb) divided by F1(which is in database Total_custs_bns), and use it to create graph.

      However, Tableau does not allow me to do that, it says cannot mix aggregate and non aggregate arguments in this function.

      It seems I cannot append two database since they have no common columns or rows.

      Since they are variables and changing over time, I cannot just do calculation by typing numbers.

      It is very urgent, if you know please help me!!!

      Thank you very much

        • 1. Re: Do calculation based on variables in two databases?

          Hello yinqiu Zhu,

           

          To resolve the issue, apply an aggregation to the Profit field, or remove the aggregation from the Sales field.

          In other cases, you may have both a dimension and a measure in your formula:

          IF [Category] = 'Technology" THEN SUM([Sales]) END

          Because Category is not aggregated, Tableau will show the same error as in the first example. Resolve the issue by applying an aggregation (ATTR) to the dimension field:

          IF ATTR([Category]) = 'Technology" THEN SUM([Sales]) END

          Although Category is a dimension, it needs to be aggregated because Sales is aggregated. 

           

          For more information about aggregations, see Aggregations.

          2 of 2 people found this helpful
          • 2. Re: Do calculation based on variables in two databases?
            Sarah Ebreo

            Hi,

             

            The "cannot mix aggregate and non aggregate arguments in this function" error you see is probably caused by using SUM for the Invst_custs_bns].[F1] field but not for the Custs field.

             

            Try using the following formula: SUM([Custs]) / SUM(Invst_custs_bns].[F1])

             

            Sarah

            2 of 2 people found this helpful