4 Replies Latest reply on Feb 21, 2018 9:54 PM by Ruchika R

    How to get coalesce funtion in tableau

    venkatesh babu sekar

      Hi All,

       

      I have four different input column , I wanted a calculated field which will return only the non null values from all the column (behave like coalesce function).

       

      Sample input :

       

          

      start_downstart_idlestart_runningF
      02/14/2018 23:07:30NULLNULLNULL
      02/14/2018 23:51:41NULLNULLNULL
      02/14/2018 23:42:51NULLNULLNULL
      0000-00-00 00:00:00.000NULLNULLNULL
      02/14/2018 23:49:50NULLNULLNULL
      NULL02/14/2018 23:42:51NULLNULL
      NULL0000-00-00 00:00:00.000NULLNULL
      NULL0000-00-00 00:00:00.000NULLNULL
      NULLNULL02/14/2018 23:07:30NULL
      NULLNULL02/14/2018 23:51:41NULL
      NULLNULL02/14/2018 23:42:51NULL
      NULLNULLNULL02/14/2018 23:07:30
      NULLNULLNULL02/14/2018 23:51:41
      NULLNULLNULL02/14/2018 23:42:51
      NULLNULLNULL0000-00-00 00:00:00.000

       

       

      Expected output:

       

          

      start_downstart_idlestart_runningFOutput
      02/14/2018 23:07:30NULLNULLNULL02/14/2018 23:07:30
      02/14/2018 23:51:41NULLNULLNULL02/14/2018 23:51:41
      02/14/2018 23:42:51NULLNULLNULL02/14/2018 23:42:51
      0000-00-00 00:00:00.000NULLNULLNULL0000-00-00 00:00:00.000
      02/14/2018 23:49:50NULLNULLNULL02/14/2018 23:49:50
      NULL02/14/2018 23:42:51NULLNULL02/14/2018 23:42:51
      NULL0000-00-00 00:00:00.000NULLNULL0000-00-00 00:00:00.000
      NULL0000-00-00 00:00:00.000NULLNULL0000-00-00 00:00:00.000
      NULLNULL02/14/2018 23:07:30NULL02/14/2018 23:07:30
      NULLNULL02/14/2018 23:51:41NULL02/14/2018 23:51:41
      NULLNULL02/14/2018 23:42:51NULL02/14/2018 23:42:51
      NULLNULLNULL02/14/2018 23:07:3002/14/2018 23:07:30
      NULLNULLNULL02/14/2018 23:51:4102/14/2018 23:51:41
      NULLNULLNULL02/14/2018 23:42:5102/14/2018 23:42:51
      NULLNULLNULL0000-00-00 00:00:00.0000000-00-00 00:00:00.000

       

       

      I have tried nested if , IFF() condition everything works only for first two column, 3rd and 4th column value are displaying as null only.

       

      TRY1 :

      If not ISNULL([F]) then [F]

      ELSEIF not ISNULL([start_running]) then [start_down]

      ELSEIF not ISNULL([start_idle]) then [start_idle]

      ELSEIF not ISNULL([start_down]) then [start_down] END

       

      Try 2 :

       

      IF (ISNULL([start_down]) and ISNULL([start_idle]) and ISNULL([start_running])) then [F]

      ELSEIF (ISNULL([F]) and ISNULL([start_idle]) and ISNULL([start_running])) then [start_down]

      ELSEIF (ISNULL([F]) and ISNULL([start_idle]) and ISNULL([start_down])) then [start_running]

      ELSEIF (ISNULL([F]) and ISNULL([start_down]) and ISNULL([start_running])) then  [start_idle]

       

      end

       

       

      Try 3 :

      IFNULL([start_running],IFNULL([start_idle],IFNULL([F],[start_down])))

       

      Can please anyone help me out.

       

      Thanks