7 Replies Latest reply on Sep 9, 2016 11:56 AM by Tom W

    showing if then else in multiple lines

    Satish Pandey

      I have a if then else statement which shows two values in last column. I want to split in two different rows first for SDMDK and second row for SDC166. Somehow my query is not working.

       

      This condition shows the output below.

      IF [Project Name] = 'PJ02388 - Keil Tools 2016' AND [Product] =  'Keil' THEN 'SDMDK, SDC166'

        ELSE "" END

      2016-09-01 16_48_21-Tableau - DSG Dashboard.png

      Using this condition, i am just getting one value..

      IF [Project Name] = 'PJ02388 - Keil Tools 2016' AND [Product] =  'Keil' THEN 'SDMDK'

          ELSEIF   [Project Name] = 'PJ02388 - Keil Tools 2016' AND [Product] =  'Keil' THEN 'SDC166'

      ELSE "" end

       

      Inplace of ELSEIF, i used OR but formula seems incorrect.

       

      Please advise.

       

      Thanks,

        • 1. Re: showing if then else in multiple lines
          Tom W

          Your calculated field can only evaluate to one value per row. Thus, it's not possible to do what you're asking - you would either need two rows in your original data, you will need to keep them in a single field like you have now, or you could try doing two separate columns instead.

          • 2. Re: showing if then else in multiple lines
            Kathryn Bridges

            Satish, I'm afraid your query is not clear...but I'll try to answer the questions I think you are asking.

             

            Are you trying to split your data into multiple rows or columns? If you want two columns, you will need two different calculations. I am not aware of any way to add rows or increase NumberofRecords once inside Tableau.

             

            If you truly want two different rows, I would duplicate the data source, adding a "source" column (Source 1, Source 2), and then union them together. That way, your If/then statement could be something like:

             

            IF [Project Name] = 'PJ02388 - Keil Tools 2016' AND [Product] =  'Keil' AND [Source]= Sheet 1 then ''SDMDK'

            ELSEIF [Project Name] = 'PJ02388 - Keil Tools 2016' AND [Product] =  'Keil' AND [Source]= Sheet 2 then ''SDC166''.

            END.

             

            Concerning your first criteria, I have often found it easier to say if CONTAINS(ProjectName,"PJ02388"), or some other iteration of this, instead of equals, in case there are any extra spaces or weird  formatting in your data. This could be why you aren't seeing your expected output, but without a workbook, I can't be sure.

             

            In your second "If/Then" statement, your "ELSEIF" does nothing.. anything that met your criteria would already been "SDMDK".

             

            Thanks

            • 3. Re: showing if then else in multiple lines
              Satish Pandey

              Hi Kathryn,

              Thanks for reply. Here is the exact issue.

               

              My tableau output looks like screenshot attached below.

              To achieve the last column i have just used simple if then else statement.

              IF [Project Name] = 'PJ02388 - Keil Tools 2016' AND [Product] =  'Keil' THEN 'SDMDK, SDC166'

                ELSE "" end

               

              output.png

              Now i want to split third last two into two row as per the last column Jira projects. I am expecting my final output as

              Keil    PJ0233- Keil Tools 2016    DEV001027 - Keil Debug - SDMDK

              Keil    PJ0233- Keil Tools 2016    DEV001027 - Keil Debug - SDC166

               

              Hope my requirement is clear now. Please advise.

              • 4. Re: showing if then else in multiple lines
                Satish Pandey

                Hi Tom, thanks for reply on my post. I just attached screenshot with clear requirement. Pls can you look at it once and advise if this is possible.

                • 5. Re: showing if then else in multiple lines
                  Tom W

                  Hi Satish,

                  Please see my original post, my answer still stands.

                  • 6. Re: showing if then else in multiple lines
                    Satish Pandey

                    Experts, Any advise on my query ?

                    • 7. Re: showing if then else in multiple lines
                      Tom W

                      Please read my original post, I've already answered your question.