Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!
Having trouble thinking through this pivot/unpivot question transform.
I have data like this:
| ID | Which fruits do you like? | How many do you have? | Which fruits do you like 2? | How many do you have 2? | Which fruits do you like 3? | How many do you have 2? |
| 101 | Apple | 4 | Plumb | 8 | Orange | 14 |
| 102 | Orange | 3 | Apple | 2 | Pear | 9 |
| 103 | Peach | 5 | Orange | 2 | Grapes | 11 |
| 104 | Grapes | 2 | Apple | 3 | Plumb | 12 |
I'm trying to get to data like this:
| 101 | Which Fruits | Apple | 4 |
| 102 | Which Fruits | Orange | 3 |
| 103 | Which Fruits | Peach | 5 |
| 104 | Which Fruits | Grape | 5 |
| 101 | Which 2 | Plumb | 8 |
| 102 | Which 2 | Apple | 2 |
| 103 | Which 2 | Orange | 2 |
| 104 | Which 2 | Apple | 3 |
| 101 | Which 3 | Orange | 14 |
| 102 | Which 3 | Pear | 9 |
| 103 | Which 3 | Grapes | 11 |
| 104 | Which 3 | Plumb | 12 |
And finally to this (which is simply conditionally changing the Which 2 and 3's to which... so I think that's not hard)
| 101 | Which Fruits | Apple | 4 |
| 102 | Which Fruits | Orange | 3 |
| 103 | Which Fruits | Peach | 5 |
| 104 | Which Fruits | Grape | 5 |
| 101 | Which Fruits | Plumb | 8 |
| 102 | Which Fruits | Apple | 2 |
| 103 | Which Fruits | Orange | 2 |
| 104 | Which Fruits | Apple | 3 |
| 101 | Which Fruits | Orange | 14 |
| 102 | Which Fruits | Pear | 9 |
| 103 | Which Fruits | Grapes | 11 |
| 104 | Which Fruits | Plumb | 12 |
Any ideas?
Thanks!
Sorry forgot the last part - add a new column to that table for which fruits:
Hi,
you could duplicate the table a couple of times and remove 2 of the which friuts and how many columns in each.
Rename all the columns to remove numbering and so they are the same in each table and then append them together, then just unpivot the which fruits column.
If I answered your question, please mark my post as solution, Appreciate your Kudos 👍
A great idea. Problem is I have about 30 groups of these with 10 each.. So might become quite cumbersome.
Ah okay, you could create a calculated table with DAX in the data view:
If I answered your question, please mark my post as solution, Appreciate your Kudos 👍
Vote for your favorite vizzies from the Power BI World Championship submissions!
If you love stickers, then you will definitely want to check out our Community Sticker Challenge!
Check out the January 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 63 | |
| 51 | |
| 41 | |
| 23 | |
| 18 |
| User | Count |
|---|---|
| 130 | |
| 111 | |
| 48 | |
| 30 | |
| 28 |