简体   繁体   中英

Tableau Create Boolean Dimension Based On Static List

So, I have a dashboard that has a list of ~24k customers from a specific population. We have some other customer populations as well, some overlap. One being ~182k customer numbers. I have been asked to, in my original dashboard of the 24k, identify which of those customers are a member of the 182k population and which ones are not. My end goal would be a table that looks something like:

CustomerNumber    MemberOf182k    ABC    XYZ
0000001           Y               123    456
0000002           N               789    012

My problem is the data in the dashboard is a custom SQL query. It pulls in my ~24k population. The 182k population isn't something that ever came from one data source - it was from multiple disparate data sources and now exists in an Excel file and a main report.

To further complicate things, our Tableau team does not like to use Excel files as data sources in Production, so I need to figure out how to create some sort of static list in Tableau (maybe a dimension) of the 182k customer numbers then do a calculated field like:

IF CONTAINS([182kPop],[24kPop])=TRUE THEN 'Y' ELSE 'N' END

Does anyone know how I'd go about this? I tried pasting a list of the 182k customer numbers right in this calculated field, but alas, it locked up on me. I was hoping I could create a list of some sort as a reference in Tableu since this list will never change and then use it as a comparison when creating a new calculated field.... Any ideas? Thanks in advance!!

Creating a static list in general is not a good idea (as you saw with your calculated field.) Tableau is not made for this; consider that it is designed to read from datasources.

You may want to clarify with the Tableau Team their reluctance to have Excel files as datasources in Production. I would guess that it is purely for refresh difficulty reasons (ie: files change locations, could be locked due to use, held on a personal machine, etc) Since your 182k list never changes, you can get around this worry of theirs by the following steps:

  1. Connect to the Excel datasource in Tableau Desktop
  2. Extract Data
  3. Publish Extract to Tableau Server.
    1. Do not give refresh permissions to published extract.

Tableau Server will not care that the underlying source of this data is Excel. It will only see that it is a Hyper Extract.

From there, you will still have some work to do as it comes to organizing and blending the data. (At this point Tableau does not support Cross Database Joins on Tableau Extracts - which would be ideal in this case.) As long as there is a common field like ID between the two, it should work. It could look like this:

在此处输入图片说明

在此处输入图片说明

在此处输入图片说明

(If the Tableau Team is worried about having even a tie to an underlying Excel datasource within an Extract, you may also consider the Tableau Data Extract API . This would require some coding, but you could essentially move from Excel into Python and into a Data Extract directly with no reference to Excel.)

In order to display the Total Ys and Ns take the following steps:

Yes Sheet:

Create the following Calculated Fields:

//[Is in 182k? (Y)]//
IF ATTR([24k ID]) = ATTR([182k].[182k ID]) THEN 1 END

~

//[WindowSum (Y)]//
If FIRST() = 0 THEN WINDOW_SUM([Is in 182k? (Y)]) END

Place them on the marks card as such: (Nothing on Rows or Columns.)

在此处输入图片说明

Right Click on [WindowSum (Y)] > Edit Table Calculation...

在此处输入图片说明

No Sheet:

Create the following Calculated Fields:

//[Is in 182k? (N)]//
IF ATTR([24k ID]) = ATTR([182k].[182k ID]) THEN NULL ELSE 1 END

~

//[WindowSum (N)]//
If FIRST() = 0 THEN WINDOW_SUM([Is in 182k? (N)]) END

Place them on the marks card as such: (Nothing on Rows or Columns.)

在此处输入图片说明

Right Click on [WindowSum (N)] > Edit Table Calculation...

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM