Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
Hi All,
I have tried using pivot and unpivot and transposing but can't quite figure out how to transform my table from this:
Any help would be appreciated
| Part Num | To Part |
| CCXCV | C7XTN |
| CCXCV | P5YFN |
| CCXCV | TNTCT |
to this:
| Part Num | Dev1 | Dev2 | Dev3 |
| CCXCV | C7XTN | P5YFN | TNTCT |
Solved! Go to Solution.
Hi, please check the below picture and the attached pbix file.
I am not sure how it is defined to understand what comes for Dev1 / Dev2 / Dev3, but I hope you get the ideas on how to create the solution for your business logic.
New Table =
ADDCOLUMNS (
VALUES ( Data[Part Num] ),
"Dev1",
CALCULATE (
MAX ( Data[To Part] ),
INDEX (
1,
SUMMARIZE (
FILTER ( Data, Data[Part Num] = EARLIER ( Data[Part Num] ) ),
Data[To Part]
),
ORDERBY ( Data[To Part] )
)
),
"Dev2",
CALCULATE (
MAX ( Data[To Part] ),
INDEX (
2,
SUMMARIZE (
FILTER ( Data, Data[Part Num] = EARLIER ( Data[Part Num] ) ),
Data[To Part]
),
ORDERBY ( Data[To Part] )
)
),
"Dev3",
CALCULATE (
MAX ( Data[To Part] ),
INDEX (
3,
SUMMARIZE (
FILTER ( Data, Data[Part Num] = EARLIER ( Data[Part Num] ) ),
Data[To Part]
),
ORDERBY ( Data[To Part] )
)
)
)
Hi,
I am not sure if I understood your question correctly, but please check the below picture and the attached pbix file.
It is for creating a new table by using DAX.
New Table =
ADDCOLUMNS (
VALUES ( Data[Part Num] ),
"Dev1",
CALCULATE (
MAX ( Data[To Part] ),
INDEX ( 1, SUMMARIZE ( Data, Data[To Part] ), ORDERBY ( Data[To Part] ) )
),
"Dev2",
CALCULATE (
MAX ( Data[To Part] ),
INDEX ( 2, SUMMARIZE ( Data, Data[To Part] ), ORDERBY ( Data[To Part] ) )
),
"Dev3",
CALCULATE (
MAX ( Data[To Part] ),
INDEX ( 3, SUMMARIZE ( Data, Data[To Part] ), ORDERBY ( Data[To Part] ) )
)
)
@Jihwan_Kim you understood the concept. Thank you.
This is very odd, and may be because I am a new user but I can't reply with a .pbix file like you did.
I am unable to get what you produced to work and might be because I provided partial data. Here is a larger sample size which has different parts and different deviations that would have to be transposed:
| Part Num | To Part |
| CCR41 | JW30H |
| CCXCV | C7XTN |
| CCXCV | P5YFN |
| CCXCV | TNTCT |
| CC0F0 | G6R99 |
| CC0F0 | 56D99 |
| CDDMJ | XX7MT |
| CF4C1 | CC0F0 |
| CGNVH | 6KNWW |
| CG0M0 | K18NP |
| CG48D | 0W8VV |
| CJMMK | 6FDH8 |
| CJX0F | WV4KK |
| CMFND | 6M9N4 |
| CMPGM | Y26KX |
| CM9TJ | X3PK1 |
| CPFWH | WCF6J |
| CPFWH | 2N6C5 |
| CP610 | 6JKXY |
| CR72X | 68ND3 |
| CTWCN | C8T2P |
| CTWCN | MGPPC |
to look like this:
| Part Num | Dev1 | Dev2 | Dev3 |
| CCR41 | JW30H | ||
| CCXCV | C7XTN | P5YFN | TNTCT |
| CC0F0 | G6R99 | 56D99 | |
| CDDMJ | XX7MT | ||
| CF4C1 | CC0F0 | ||
| CGNVH | 6KNWW | ||
| CG0M0 | K18NP | ||
| CG48D | 0W8VV | ||
| CJMMK | 6FDH8 | ||
| CJX0F | WV4KK | ||
| CMFND | 6M9N4 | ||
| CMPGM | Y26KX | ||
| CM9TJ | X3PK1 | ||
| CPFWH | WCF6J | 2N6C5 | |
| CP610 | 6JKXY | ||
| CR72X | 68ND3 | ||
| CTWCN | C8T2P | MGPPC |
Hi, please check the below picture and the attached pbix file.
I am not sure how it is defined to understand what comes for Dev1 / Dev2 / Dev3, but I hope you get the ideas on how to create the solution for your business logic.
New Table =
ADDCOLUMNS (
VALUES ( Data[Part Num] ),
"Dev1",
CALCULATE (
MAX ( Data[To Part] ),
INDEX (
1,
SUMMARIZE (
FILTER ( Data, Data[Part Num] = EARLIER ( Data[Part Num] ) ),
Data[To Part]
),
ORDERBY ( Data[To Part] )
)
),
"Dev2",
CALCULATE (
MAX ( Data[To Part] ),
INDEX (
2,
SUMMARIZE (
FILTER ( Data, Data[Part Num] = EARLIER ( Data[Part Num] ) ),
Data[To Part]
),
ORDERBY ( Data[To Part] )
)
),
"Dev3",
CALCULATE (
MAX ( Data[To Part] ),
INDEX (
3,
SUMMARIZE (
FILTER ( Data, Data[Part Num] = EARLIER ( Data[Part Num] ) ),
Data[To Part]
),
ORDERBY ( Data[To Part] )
)
)
)
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 48 | |
| 43 | |
| 39 | |
| 19 | |
| 17 |
| User | Count |
|---|---|
| 67 | |
| 63 | |
| 30 | |
| 30 | |
| 23 |