3 Replies Latest reply on Aug 9, 2016 2:13 PM by Joe Oppelt

    Using Parameters to Filter between two Data Sources on one Sheet/Graph - "All Fields Must Be Aggregate or Constant" Issue

    Joseph Kovar


           I recently created a Tableau Sheet/Dashboard in which I have two different data sources both plotted on the same graph/worksheet (linked through a common date field). I created a Parameter (lets call it "Sold Vs Inforce" that contains "Sold / In-Force" (Sold = 1 / In force = 2 as integers) as drop-down options.


      I have multiple metrics/calculations that are similar between the two sources  - and I create new calculated fields that point at one of the two sources depending on the parameter:

                                  New Metric =

                                     IF [Sold Vs. In-Force] = 1

                                   Then [Total  Packages] / [Total Policies]

                                    elseIF   [Sold Vs. In-Force] = 2

                                   Then [source2].[Total  Packages] / [source2].[Total Policies]

                                    else null end.


      Because Total Packages and Total Policies are both aggregated metrics - this formula works (when I use a drop down on Sold Vs Inforce -- it toggles between my "Sold" source and "In Force" Source to calculate "New Metric" according to either data source.


      I need to replicate this exact process for a *non aggregate / non-numeric* metric (in this case, "Channel"). When I try the similar function:

                                  New Channel Metric =

                                     IF [Sold Vs. In-Force] = 1

                                   Then        Channel

                                    elseIF   [Sold Vs. In-Force] = 2

                                   Then [source2].[Channel]

                                    else null end.


      Unlike the aggregated functions - this does not work for Channel - it gives me a "All Fields must be aggregate or constant when using table calculation fields or fields from multiple data sources" Error - cannot use the parameter to create a "Channel" Filter. I've already tried using specific Aggregate functions (such as Attr(Channel)) - but it does not filter accordingly. I also tried linking "Channel" from source 1 to source 2 - this did not work either.


      Has anyone else come across this issue or found a solution to this problem? If there is any other way of creating a Filter that affects multiple data sources at the same time>