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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
ddalton
Resolver I
Resolver I

Create new table that sums rows based on matching column value

I have a table containing data with columns containing a reference (non-unique) and a type (non-unique). A representation is below:

 

TableA

ReferenceTypeValue
A123Type15521
A123Type1321
A123Type210
B321Type1450
B321Type2300
C231Type15000
C231Type2500
C231Type2550
.........

 

I would like to create a new summary table that has a row for each reference and columsn that some the values for each type, as below:

 

TableB

ReferenceType1Type2
A123584210
B321450300
C23150001050

 

I've created new Tables that simply Summarize columns from an existing Table and then created new Columns based on those (i.e., like the difference between two values etc.) but I'm not sure how to achieve this. 
1 ACCEPTED SOLUTION
SpartaBI
Community Champion
Community Champion

@ddalton create this calculated table:

 

 

TableB = 
ADDCOLUMNS(
    VALUES('TableA'[Reference]),
    "Type1", CALCULATE(SUM('TableA'[Value]),'TableA'[Type] = "Type1"),
    "Type2", CALCULATE(SUM('TableA'[Value]),'TableA'[Type] = "Type2")
)

 

 

 

SpartaBI_0-1656489871296.png

 


2022-05-19 17_30_22-Re_ Need help on DAX function with measure vs colu... - Microsoft Power BI Commu.png


Full-Logo11.png

SpartaBI_3-1652115470761.png   SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

Showcase Report – Contoso By SpartaBI

View solution in original post

9 REPLIES 9
SpartaBI
Community Champion
Community Champion

@ddalton create this calculated table:

 

 

TableB = 
ADDCOLUMNS(
    VALUES('TableA'[Reference]),
    "Type1", CALCULATE(SUM('TableA'[Value]),'TableA'[Type] = "Type1"),
    "Type2", CALCULATE(SUM('TableA'[Value]),'TableA'[Type] = "Type2")
)

 

 

 

SpartaBI_0-1656489871296.png

 


2022-05-19 17_30_22-Re_ Need help on DAX function with measure vs colu... - Microsoft Power BI Commu.png


Full-Logo11.png

SpartaBI_3-1652115470761.png   SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

Showcase Report – Contoso By SpartaBI

As simple as that 😉

 

Thanks! 

SpartaBI
Community Champion
Community Champion

@ddalton my pleasure 🙂
Hey, check out my showcase report - got some high level stuff there. Sure you will find there a lot of cool ideas. 
https://community.powerbi.com/t5/Data-Stories-Gallery/SpartaBI-Feat-Contoso-100K/td-p/2449543
Give it a thumbs up over there if you liked it 🙂

The original table also has some other columns in it that would be useful. For example, there could be a customer reference that is specific to the reference 

ReferenceTypeValueCust
A123Type15000AAA
A123Type2150AAA
A123Type2300AAA
B321Type14500BBB
B321Type11500BBB
B321Type2100BBB
B321Type2250BBB
C231Type11000AAA
C231Type2350AAA
C231Type2150AAA

 

So, in addition to your original solution, could I also include the Cust column in the data set? i.e.,:

 

ReferenceType1Type2Cust
A1235000450AAA
B3216000350BBB
C2311000500AAA

 

SpartaBI
Community Champion
Community Champion

@ddalton for each refrence there can only be 1 customer?

Please don't check out my showcase report and give it a thumbs up over there if you liked it 🙂 
https://community.powerbi.com/t5/Data-Stories-Gallery/SpartaBI-Feat-Contoso-100K/td-p/2449543

Ah. No, there is more than one reference per customer. I've updated the original reply above to include, for example, reference C231 and show that is also linked to Cust AAA.

 

So, there is multiple references per customer. 

SpartaBI
Community Champion
Community Champion

@ddalton you mean like this? :

 

TableB = 
ADDCOLUMNS(
    ALL('TableA'[Reference], TableA[Cust]),
    "Type1", CALCULATE(SUM('TableA'[Value]),'TableA'[Type] = "Type1"),
    "Type2", CALCULATE(SUM('TableA'[Value]),'TableA'[Type] = "Type2")
)

 


2022-05-19 17_30_22-Re_ Need help on DAX function with measure vs colu... - Microsoft Power BI Commu.png


Full-Logo11.png

SpartaBI_3-1652115470761.png   SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

Showcase Report – Contoso By SpartaBI

Exactly like that. Thank you! 

SpartaBI
Community Champion
Community Champion

@ddalton my pleasure 🙂
Don't forget about the report please 🤣
https://community.powerbi.com/t5/Data-Stories-Gallery/SpartaBI-Feat-Contoso-100K/td-p/2449543
Give it a thumbs up over there if you liked it 🙂

Helpful resources

Announcements
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! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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