2015-04-01 30 views
1

創建層次結構這是我的數據集的樣子:無法在數據透視表

ItemType  ItemCategory   ItemName 
ItemType1  ItemCat1    Item1 
ItemType1  ItemCat1    Item2 
ItemType1  ItemCat2    Item3 
ItemType2  ItemCat1    Item4 
ItemType2  ItemCat2    Item5 
ItemType2  ItemCat2    Item6 
ItemType3  ItemCat1    Item7 
ItemType3  ItemCat2    Item8 
ItemType3  ItemCat1    Item9 

我試圖在數據透視表中顯示,這樣我可以用ItemCategory獲取樹視圖樣的結構爲行而不是列。

ItemType  ItemCat1  ItemCat2 
ItemType1  Item1   Item3 
       Item2 

ItemType2  Item4   Item5 
           Item6 

ItemType3  Item7   Item9 
       Item8 

要做到這一點,這就是我所做的。

我將ItemType和ItemCategory創建爲Dimensions和ItemName作爲Expression。但它不會顯示ItemName列中的數據。

我創建了ItemType,ItemCategory和ItemName作爲Dimensions,但它不讓我拖放ItemCategory列在ItemName之上。但是它顯示數據。

我創建ItemType,ItemCategory和ItemName作爲Dimensions和ItemName作爲Expression,它允許我將ItemCategory拖放到ItemName表達式列的頂部,但結果不是我正在尋找的。

我在這裏失蹤了什麼?

回答

0

我想我能夠實現你的目標。使用

解決方案:

  • 的ItemType和ItemCategory作爲尺寸。
  • ItemName用於Expression,Concat(ItemName,chr(13))
  • 在數據透視表屬性的Presentation選項卡中,勾選Wrap Cell Text複選框以便在單元格中顯示多行。

這裏的訣竅是Concat函數。由於您對同一個ItemCategory和ItemType有多個ItemName,因此需要將它們放在一起。 Concat執行它,通常會生成一個逗號分隔的字符串(你也可以在這裏使用Concat(ItemName,','))。

使用表達式Concat(DISTINCT ItemName,chr(13))也可能是一個好主意,以確保您沒有在同一個單元格中重複的ItemNames。

+0

感謝您的回覆,但我不想要Concat項目名稱。我希望它們分開顯示。 – Asdfg 2015-04-02 13:30:21