3 Replies Latest reply on Feb 20, 2017 5:29 PM by Sherzodbek Ibragimov

    Using dynamic parameter for multiple data types and calculations

    Mike Lane

      Looking for help from someone with creating a drop down dynamic parameter for color.  I also wanted to create a filter by the same dynamic parameter, so I can then filter by color. The issue is that I am trying to place both string measures and float measures either under one parameter, so the user can choose what measure they can use as color.  I have seen a few similar requests that seem to come close to what I want:

       

      Who Says Parameters Aren’t Dynamic? | THE MARKS CARD

      Use Parameters to Make Views More Interactive

      Using Multiple Dimensions Under One Filter

      Filtering Multiple Dimensions Using Parameters | Tableau Software

      Creating a Dynamic “Parameter” with a Tableau Data Blend | Drawing with Numbers

      However, they are only just for dimensions, just for float measures, or just for strings.  All of them suggest created a parameter then calculated field.  I did that as suggested; however, I keep getting the "expecting float" or "expecting string" error.  Can anyone help?

       

      (See the sheet labeled "Test")

       

      Message was edited by: Mike Lane.   I uploaded a new version of .twbx to help clarify my question.

        • 1. Re: Using dynamic parameter for multiple data types and calculations
          Sherzodbek Ibragimov

          Mike,

          Instead, can you just make 2 parameters: one for measures and one for dimensions?

          • 2. Re: Using dynamic parameter for multiple data types and calculations
            Mike Lane

            Sherzodbek Ibragimov  Thank you, first, for trying to tackle this hard question, and I think your onto something but I need to clarify my question.  The issue I am having is not so much dimension vs. measure as it data-type string vs. data-type float (number).  Its also a secondary issue of aggregated calculation vs. measures.  To clarify this, I went back to the original test.twbx and turned the only dimension Discovery method into a calculated string measure like [Habitability Zone] and [HZC Clustering], which I called [Disc_method].  Then I fixed my dynamic parameter [Parameter.Show Color], and the drop-down calculation [Change Color].  As I have highlighted below, the calculated field [Change Color] still has the issue of "expecting string and found float" because ESI is a number while the other three calculations are strings.

             

            The calculated field "Change Color":

            CASE [Show Color]

            WHEN 'Habitability Zone' THEN [Habitability Zone]

            WHEN 'HZC Clustering' THEN [HZC Clustering]

            WHEN 'Disc_method' THEN [Disc_method]

            WHEN 'ESI' THEN [ESI]

            ELSE ''

            END

             

            Going back to your original point, I might ask, "Can I just make 2 parameters one for string calculations and one for float calculations?"  My answer would be I don't know how I would do that so that multiple parameters are seen by the end user as one single calculation that is being used a single drop down list.  Can you show me how?

             

             

            P.S. Honestly, I have also tried using the dynamic filters which don't use the CASE/When syntax, but I still run into the issue of strings vs. floats.

            • 3. Re: Using dynamic parameter for multiple data types and calculations
              Sherzodbek Ibragimov

              Mike,

              Whenever you use IF or Case statement, they can't be mixed, (just like in your case). So, they should be either string or numbers, but not both. However, if you convert ESI to string with STR() function, then you should be able to use 'Change Color' dimension. Looks like you deleted you new updated workbook as I don't see it now. Hope it helps.