Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
949184_soy
Regular Visitor

Unpivot column using DAX shows error "Column name already exist"

Hi everyone I am trying to unpivot this columns using DAX, the name is TABLE

 

949184_soy_0-1715783739235.png

 

Into this:

 

949184_soy_1-1715783772658.png

 

Using this code: 

 

 

TablaAuxiliar = 
UNION(
    GENERATE(
        FILTER(TABLA, NOT(ISBLANK([NAME_01]))),
        ROW(
            "Id", [Id],
            “Name", [NAME_01],
            “Company", [COMPANY_01],
            "Department", [DEPARTMENT_01],
            “Role", [ROLE_01]
        )
    ),
    GENERATE(
        FILTER(TABLA, NOT(ISBLANK([NAME_02]))),
        ROW(
            "Id", [Id],
            "Name", [NAME_02],
            "Company", [COMPANY_02],
            "Department", [DEPARTMENT_02],
            " Role", [ROLE_02]
        )
    )     
    )

 

 

But I am geeting this error 

 

"The Column with the name of Id already exist in the TablaAuxiliar Table"

 

949184_soy_2-1715784032275.png

 

Any help will be appreciated. 

 

Regards

 

 

2 ACCEPTED SOLUTIONS
audreygerred
Super User
Super User

You can create what you need in Power Query. I would remove the _02 columns as a step in Power Query, then rename the _01 columns to just be NAME, COMPANY, DEPARTMENT, and ROLE. Next, duplicate that query and remove your rename and removed column steps, then remove the _01 columns and rename the _02 columns to NAME, COMPANY, DEPARTMENT, and ROLE. Next, append the two queries together wither as a new query or within one of the two that are there.

 




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





View solution in original post

Transformations like this should be pushed as far upstream as possible. If it is not possible to have the source be the way you need it, the next best place is Power Query. Doing it via DAX (if even possible) would not be the best approach. Hope this helps!




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





View solution in original post

3 REPLIES 3
audreygerred
Super User
Super User

You can create what you need in Power Query. I would remove the _02 columns as a step in Power Query, then rename the _01 columns to just be NAME, COMPANY, DEPARTMENT, and ROLE. Next, duplicate that query and remove your rename and removed column steps, then remove the _01 columns and rename the _02 columns to NAME, COMPANY, DEPARTMENT, and ROLE. Next, append the two queries together wither as a new query or within one of the two that are there.

 




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Thank you for your response, I manage to append the tables 01 and 02. Despide of the above I wonder if there is a DAX formula because in the real dataset has 20 columns 01 to 20. 

 

Cheers

Transformations like this should be pushed as far upstream as possible. If it is not possible to have the source be the way you need it, the next best place is Power Query. Doing it via DAX (if even possible) would not be the best approach. Hope this helps!




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.