Madhumita
Madhumita

Reputation: 499

How to create a dimension calculated field by concatenating index() with a text field

I have created a calculated field(Row No.), where the calculation is, Index(). Then tried to concatenate it with a field(Name) which has text data. Then I created another calculated field(Concat), where the calculation is, attr([Name])+'_'+str([Row No.]). The Concat field is showing under Measures. How can I have it as a Dimension ?

How can I create a calculated field which will make each entry in 'Name' field by adding an 'underscore' and a number to it ?

Upvotes: 0

Views: 5904

Answers (2)

Alex Blakemore
Alex Blakemore

Reputation: 11919

You can't have a dimension based upon a call to a table calc function (such as index()), nor an aggregate function (such as sum()).

You can however convert a measure to discrete, which will allow you to use it to create headers in your view.

There is a good reason for this restriction. Dimensions are used early in the order of operations to partition data rows into blocks. They are effectively the group by clause in a SQL statement. Aggregate functions such as sum() are then applied to each partition, and table calcs are applied even later to the aggregated query results. So you can't use those results to go back in time and generate a different partition of your data rows -- which is why Tableau won't allow you to make those fields into dimensions.

Luckily, once you understand the order of operations, you can usually find other ways to get effect you need.

As a footnote, you can create a dimension based on a FIXED LOD calculated field that includes calls to an aggregate function -- such as { FIXED [Region] : CountD([Customer]) }.

Upvotes: 0

Bernardo
Bernardo

Reputation: 3348

There are two possible ways to have it as a Dimension. First, the 'ATTR' is creating an aggregation, which is why it is a measure. You should be able to remove this and still concatenate with [Name]+'_'+str([Row No.]).

second, you should be able to right click on the Measure and select Convert to Discrete, then click and drag it to the Dimensions section.

Upvotes: 1

Related Questions