Mohamed ElSheikh
Mohamed ElSheikh

Reputation: 177

Unpivot data in Tableau Converting Rows to Columns

I have this data in Tableau:

KPI_NAME    Value   Date

------------------------

A     2     1-Jan

B     4     1-Jan

A     6     2-Jan

B     7     2-Jan


and I want it like this:

A     B     Date

------------------------

2     4     1-Jan

6     7     2-Jan

So I want it to convert each distinct value in the column KPI_NAME to a separate row, this can be done in the visualization part in Tableau but I want to do that in the data preparation because I want to use it in calculated field

Any help is appreciated.

Upvotes: 1

Views: 2218

Answers (1)

tyvich
tyvich

Reputation: 580

Most tableau functionality is designed to consume more granular, flattened, and tidy data in the form of your first set. As such, the data prep functionality has a feature to unpivot column values into rows. I don't believe that reverse functionality is built into the data prep capability in the same way.

Not knowing your end use case, potentially a work around would be to:

  • Create a calculated field with an IF statement to return the value when record is listed as A, otherwise return NULL.

Although you will still have the same number of records, you should be able to perform many of the calculations available with this type of data structure

Alternatively, you could perform you pivot outside of Tableau.

Upvotes: 2

Related Questions