如何创建等于许多属性之一的计算字段

How to create a calculated field that equals one of many attributes

有以下数据

Product   AttributeType  AttributeValue
Ferrari   Color          Red
Ferrari   Wheels         4
Porsche   Color          Silver
Porsche   Wheels         4
Yamaha    Color          Black
Yamaha    Wheels         2

我如何创建一个计算字段 "Color"/"Wheels" 给我相应的 color/wheels?

我尝试做类似

的事情
{FIXED [AttributeValue]: [AttributeType]="Color"}

但是 Tableau 抱怨说 [AttributeType]="Color" 不是聚合函数。

有什么想法吗?

将数据重塑为具有 Color 列和 Wheels 列会更简单,但如果您不想这样做,则可以使用以下聚合计算。

attr(if AttributeType = "Color" then AttributeValue end) +  "/" +
attr(if AttributeType = "Wheels" then AttributeValue end)

如果您有多种颜色或轮子属性给定尺寸,attr() 函数将 return“*”