4 Replies Latest reply on Nov 30, 2017 10:24 PM by Anthony Cua

    LOD Conditions and String Outputs

    Anthony Cua

      So... I have this calc field in my sheet and it works:



      IF {FIXED:COUNTD([campaign])}={INCLUDE:COUNTD([campaign])}

      THEN 1 ELSE 0



      But the moment I change my "1" and "0" to string, it messes up the formula and it attempts to show a count instead.

      Is this a limitation in Tableau? I tried searching but I can't find any related info either.


      Attached is a TWBX for ref (see CALC1 measuret field).

        • 1. Re: LOD Conditions and String Outputs
          Jack Watts

          Hey Anthony,


          Not sure why this is the case, but if you right click and change the aggregation from Count to Min, it should give you what you want.


          Alternatively you can stick it in the actual calculation, so it'd be


          MIN(IF { FIXED :COUNTD([Campaign])} = { INCLUDE :COUNTD([Campaign])}

          THEN "All campaigns selected"

          ELSE "Nope"




          1 of 1 people found this helpful
          • 2. Re: LOD Conditions and String Outputs
            Anthony Cua

            Whoa. You're right! Changing aggregate to MIN fixed it. I'm soo confused and happy at the same time. Haha.


            Thanks so much Jack!

            • 3. Re: LOD Conditions and String Outputs
              Jack Watts

              Not a problem mate. My guess it has something to do with the fact that you're creating an aggregate/table calculation, so Tableau needs to know how to parse what you've created. While a numerical response can default to sum, average, whatever, a string measure will generally default to count. For example, if you drag one of your string dimensions to the measures field, you'll see it default to count as long as the field is discrete. Because the field is designed to essentially be the same value for all levels of detail, min or max will get you the same answer, since there's only one value across everything.


              You'll see this when you pull the calculation you were originally having trouble with into the measure text marks. It provides "1" as the count of calc 1, so it's only seeing one value.


              Alternatively, you could right click and select "attribute" instead of measure -> count from the original calculation in the workbook you provided. Should all give you the same thing


              This is my attempt to summarize what's happening so shouldn't be taken as gospel - hope it's not too confusing.

              1 of 1 people found this helpful
              • 4. Re: LOD Conditions and String Outputs
                Anthony Cua

                It does help alot. And I like your sample about counts. It reminds me of how Excel uses counts for text, and sums for numerics. I guess that's a good hint that I may need to get the min value as opposed to other aggregations that won't work with strings.