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
zzzsharepoint
Helper I
Helper I

How to add two rows and create a new column in Power Bi

I have this table 

Class                       Category                        Cost
A                        CPU                           4
A                        Memory                           3
A                        Network                           10
A                        Disks                           2
B                        CPU                           4
B                        Memory                          10
B                       Disks                           11

 

And the table I want is to add rows of CPU and Memory for each Class and at last it turns out like this. How can I do this?

Class                       Category                        Cost
A                        CPU&Memory                           7
A                        Network                           10
A                        Disks                           2
B                        CPU&Memory                           14
B                       Disks                           11
1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @zzzsharepoint 

 

You can try the following methods.
Column:

New Category = IF(OR([Category]="CPU",[Category]="Memory"),"CPU&Memory",[Category])
Sum Cost = 
CALCULATE ( SUM ( 'Table'[Cost] ),
    FILTER ( 'Table',
        [Class] = EARLIER ( 'Table'[Class] )
            && [New Category] = EARLIER ( 'Table'[New Category] )
    )
)

vzhangti_0-1672996013591.png

New Table:

New table = SUMMARIZE('Table','Table'[Class],'Table'[New Category],'Table'[Sum Cost])

vzhangti_1-1672996082546.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
v-zhangti
Community Support
Community Support

Hi, @zzzsharepoint 

 

You can try the following methods.
Column:

New Category = IF(OR([Category]="CPU",[Category]="Memory"),"CPU&Memory",[Category])
Sum Cost = 
CALCULATE ( SUM ( 'Table'[Cost] ),
    FILTER ( 'Table',
        [Class] = EARLIER ( 'Table'[Class] )
            && [New Category] = EARLIER ( 'Table'[New Category] )
    )
)

vzhangti_0-1672996013591.png

New Table:

New table = SUMMARIZE('Table','Table'[Class],'Table'[New Category],'Table'[Sum Cost])

vzhangti_1-1672996082546.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

zzzsharepoint
Helper I
Helper I

@amitchandak I checked the video what you have shared and that has no where with the question asked. I am not looking to summarize all the rows here.. its only one with values CPU and Memory and also looking to add the Cost for these values. I am looking to get that as a new table. Your Video talks about summarize function which I cant use here. Please check the question and respond.

amitchandak
Super User
Super User

@zzzsharepoint , use the power query and table method

Concatenate Text- Measure, DAX Table, and Power Query Table: https://youtu.be/xAh3tz1qo24

And I am looking to Add two values not just concatenate two strings

Can you please show with an example?

 

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.