Forum Discussion
yaudje
3 years agoFrequent Visitor
Transpose a table
Hi Folks,
Im having a hard time transposing the table. Just need the Dax for the Output Table basis the Source table. Your response will be a big help.
Thanks in advance.
Hi yaudje ,
This is better done on Power Query using the Unpivot option however in dax you can use the following code:
Table 2 = UNION( SELECTCOLUMNS('Table', "Sales", 'Table'[Sales],"Area", 'Table'[Area], "Year", 2019, "value", 'Table'[2019]), SELECTCOLUMNS('Table',"Sales", 'Table'[Sales],"Area", 'Table'[Area], "Year", 2020, "value", 'Table'[2020]), SELECTCOLUMNS('Table',"Sales", 'Table'[Sales],"Area", 'Table'[Area], "Year", 2021, "value", 'Table'[2021]))
3 Replies
- MFelixSuper User
Hi yaudje ,
This is better done on Power Query using the Unpivot option however in dax you can use the following code:
Table 2 = UNION( SELECTCOLUMNS('Table', "Sales", 'Table'[Sales],"Area", 'Table'[Area], "Year", 2019, "value", 'Table'[2019]), SELECTCOLUMNS('Table',"Sales", 'Table'[Sales],"Area", 'Table'[Area], "Year", 2020, "value", 'Table'[2020]), SELECTCOLUMNS('Table',"Sales", 'Table'[Sales],"Area", 'Table'[Area], "Year", 2021, "value", 'Table'[2021]))