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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
Surya1
Helper I
Helper I

dax

I have a table

 

col a     colb

 

x           0

x           1

y           2

y           0

y           1

z           0

 

 

 

I want to create a new table

 

New Table

 

col A    col B(sum of values for each col a)

 

x            1

y            3

z            0

 

 

can someone help me with the dax

1 ACCEPTED SOLUTION
v-xjiin-msft
Solution Sage
Solution Sage

Hi @Surya1,

 

In your scenario, you can use SUMMARIZE() function to create a new calculated table. Please refer to following sample:

 

Table-2 =
SUMMARIZE ( 'Table-1', 'Table-1'[col a], "col B", SUM ( 'Table-1'[col b] ) )

4.PNG

 

Thanks,
Xi Jin.

View solution in original post

6 REPLIES 6
v-xjiin-msft
Solution Sage
Solution Sage

Hi @Surya1,

 

In your scenario, you can use SUMMARIZE() function to create a new calculated table. Please refer to following sample:

 

Table-2 =
SUMMARIZE ( 'Table-1', 'Table-1'[col a], "col B", SUM ( 'Table-1'[col b] ) )

4.PNG

 

Thanks,
Xi Jin.

vega
Resolver III
Resolver III

Do you absolutely need to do this through DAX? The query editor is very easy to use. You can get the same results by selecting 

 

Edit Queries -> right click on your table and select Duplicate -> Go to the newly duplicated table and left click on col a and select Group By -> Group by col a and select Sum under Operation

 

This will give you the results that you want. If you have to do it through DAX via a calculated table, I can provide instructions for that as well, just let me know.

Thank you for your time.Can you please help me with the dax solution

You will select New Table -> The formula will be the following:

col a = DISTINCT(Table1[col a])

You will then go to the Relationships tab and form a relationship between the col a of both tables.

 

Then return to the new table and select New Column -> The formula will be:

Col b := CALCULATE(SUM(Table1[col b]))

 Where Table1 is the original table name.

 

This dax gives the sum of colb.I want the sum of col b tat comes under each cola.

Did you form a relationship between the two tables? If you did not then you are going to get the sum total for all value in col a. After forming the relationship, you get the following:

 

Capture.PNG

 

The solution that @v-xjiin-msft posted should also work as well.

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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