1

I am executing a New Custom SQL with CASE-choice fields in Tableau:

SELECT x1, x2, x3 ..., 
   CASE WHEN x1>1 THEN 'y'
        ELSE '' END  AS x_new
   ...
FROM table1a 
 FULL JOIN table2a...
WHERE x3>4

UNION ALL 

SELECT x1, x2, x3 ...,
   CASE WHEN x1>1 THEN 'y'
        ELSE '' END AS x_new
   ...
FROM table1b
 FULL JOIN table2b
WHERE x3>4 ...

It's a live connection with database. I tried to work with an extract too. The problem here is that CASE-generated fields are not possible to work with in the worksheet. The standard fields (right after SELECT-statement) behave fine, no issue with them.

I know I may just query and then create a group of calculated fields. It's ok. However, maybe someone can explain why fields created via CASE-statement in the custom SQL are unusable. I am trying to understand if it's an error on my side or it's Tableau limitations.

casey
  • 11
  • 3
  • Would need to see an entire query for 1 statement w/o union. Are you getting an error when you try this? if so what error? if you try the Custom SQL using a direct connection to the database does the custom SQL work? if not what error? Are all the "Union ed" fields of the same data type? Do you have a `,` before the case? Did you try just adding a `'demo' as Test` without case to see if the worksheet works with a created column? So many things to consider... – xQbert Jun 03 '19 at 16:11
  • @xQbert SQL works well, no mistakes in the query itself. Fields are created, and displayed in the Data Source as well as those fields are in the dimensions and measures of the worksheet. No errors. It's just when I try to drag those variables to the Columns / Rows. The resulting worksheet doesn't display any result. It goes simply white, like freezes. No error messages. While measures/ dimensions that were just queried directly (not under CASE-statement) work fine, and results displayed on the worksheet. Problem with variables created with (CASE when ... then ... end) -statement. – casey Jun 03 '19 at 17:40
  • When you connect to datasource then are you able to see data in the window, not in sheet – Siva Jun 03 '19 at 17:43
  • @Siva yes, all data in the Data Source section displayed as expected – casey Jun 03 '19 at 17:59
  • Are you sure your where clause doesn't exclude all those where x1>1 thus all cases would be empty set? So the query itself is returning some 'y' values correct? Trying to figure out of any of the linked apply: https://kb.tableau.com/articles/issue/worksheet-does-not-show-certain-values-after-using-a-calculated-field – xQbert Jun 03 '19 at 18:00
  • xQbert it's not an empty set, logic is right. I run query in Python first, and then in Tableau. All columns displayed correctly. Fields that "constructed with" CASE display either 'Y' or empty values. I also created a calculated field to "code" these fields to a measure: (if 'y' then 1 else 0 end), and this calculated field displayed in the Data Source and calculated correctly. But, even this field doesn't behave well -> my attempt to drag it to the worksheet results to 'white frozen state'. There must be something with this 'CASE'-calculated fields. I am not sure if it's on my side. – casey Jun 03 '19 at 18:21
  • xQbert thank you for the link, i'll browse through – casey Jun 03 '19 at 18:23

0 Answers0