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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Jannis68
Frequent Visitor

Creating a new table in Power BI combining columns

I need to create a new table combining six columns into two columns and keep the identifiers. The exisiting table is:

 

question_idrespondent_idPos1Pos2Pos3Neg1Neg2Neg3
11x     
21x     
31x     
12xx     
22xx     
32x     

 

The new table should look like this:

 

question_idrespondent_idPositiveNegative

 

Positive should be a union of Pos1, Pos2, Pos3 and Negative Neg1, Neg2, Neg3

 

Any thoughts?

 

 

 

 

 

 

 

 

1 ACCEPTED SOLUTION
v-ljerr-msft
Employee
Employee

Hi @Jannis68,

 

If I understand you correctly, you should be able to use the Unpivot Columns option in Query Editor to unpivot the Pos columns and Neg columns separately to get the expected result in your scenario.

 

For more details about how to Pivot and Unpivot with Power BI, you can refer to this article. Smiley Happy

 

Regards

View solution in original post

7 REPLIES 7
v-ljerr-msft
Employee
Employee

Hi @Jannis68,

 

If I understand you correctly, you should be able to use the Unpivot Columns option in Query Editor to unpivot the Pos columns and Neg columns separately to get the expected result in your scenario.

 

For more details about how to Pivot and Unpivot with Power BI, you can refer to this article. Smiley Happy

 

Regards

Rfranca
Resolver IV
Resolver IV

hi, @Jannis68

 

When do you want to make that combination?
When importing data or when creating a measure?
Because depending on the moment you can use DAX functions or M functions.

Of more details of the moment of this combination.

I have no preference wheter using on import or when creating a DAX.

@Jannis68

 

Using DAX you can create a calculated Table

 

Go to Modelling Tab>>>NEW TABLE and use this formula

 

Table =
SUMMARIZE (
    TableName,
    TableName[question_id],
    TableName[respondent_id],
    "Positive", SUM ( TableName[Pos1] ) + SUM ( TableName[Pos2] )
        + SUM ( TableName[Pos3] ),
    "Negative", SUM ( TableName[Neg1] ) + SUM ( TableName[Neg2] )
        + SUM ( TableName[Neg3] )
)

 

 


Regards
Zubair

Please try my custom visuals

Thanks for input. Actually this is not what I was looking for.  I would like the new table to look like:

 

question_idPositiveNegative
1Pos1Neg1
1Pos2Neg2
1Pos3Neg3
2Pos1Neg1
2Pos2Neg2
2Pos3Neg3

 

 

Hi,

 

For further clarity, please take a clearer example.  Instead of xx, show some data under the Pos and negative columns and on that dataset, show your desired result.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

@Jannis68

 

Using Query Editor,

 

You can add new columns ...

Select the Columns you want to sum/combine>>>Go to "Add Column" Tab>>>Statistics>>>sum

 

Picture below shows this

 

5894.png

 


Regards
Zubair

Please try my custom visuals

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.