1 Reply Latest reply on Apr 30, 2012 9:17 AM by Marc Engle

    Facing problem in "if statement"....?

      Suppose I have below data in excel format

                   Frequency

                 ------------------

                     Daily

                     Daily

                     Monthly

                     Monthly

                     Daily

                     Daily

                     Monthly

      Now I want to count the frequency if its value is 'Daily'. for this I create calculated field and use the following formula

       

      If [Frequency]="Daily" Then Count([Frequency])

      end

       

      but it shows error message "Can not mix Aggregate and Non aggregate comparisions"

      How I got this?

        • 1. Re: Facing problem in "if statement"....?
          Marc Engle

          HI Jairaj,

               Tableau doesn't allow you to mix aggregate functions like Count that work on multiple rows at once with scalar functions like an if statement that work on a single row at a time.  To achieve what you're asking about, set up a calculated field that has the "If [Frequency] Then 1 End"  Then you can drop a pill for that calculated field on whichever shelf you want to that has the aggregation of "Count" or "Sum" or whatever level it is that you wish.

           

          Regards,
          Marc

           

          Message was edited by: Marc Engle -- Added clarifying text about dropping the calculated field's pill on a shelf.