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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Help with DAX creating new table and sum from multiple tables

Hi,

 

I'm struggling to create a table using DAX and getting what I think are simple totals. My goal is to get a table with 2 values: Customer_ID and Product_Count. Customer_ID is the unique ID for a customer. A customer can have 1 more accounts (free checking, savings, 12 month money market, etc.) and every type of account (270 total) belong to 1 of 5 products. Think of a product as the main category and the account is the sub-category.

 

Here are my tables:

 

Customer_Final:
-----------------
Customer_ID (PK)

 

Accounts_Final:
-----------------
Account_ID (PK)
AccountNumber
Customer_ID (FK)
Sub_Product_ID (FK)

 

Sub_Products_Final
----------------
Sub_Product_ID (PK)
Product_ID (FK)

 

Products_Final
----------------
Product_ID (PK)

 

No customer can have more than 5 for Product_Count as this is the max number of products.

My table is returing 270 for every Customer_ID. That's the total number of accounts types I have, so clearly I'm doing something wrong. 

 

Below is my code.  I'm assuming I need a join between Sub_Products_Final and Products_Final but can't get it to work.

 

Customer_Product_Count = SUMMARIZE(
Accounts_Final, Accounts_Final[Customer_ID],
"Product Count", COUNT(Sub_Products_Final[Sub_Product_ID]))

 

What am I doing wrong?

 

Thanks,
Mark

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

Maybe a measures total problem? This looks like a measure totals problem. Very common. See my post about it here: https://community.powerbi.com/t5/DAX-Commands-and-Tips/Dealing-with-Measure-Totals/td-p/63376

Also, this Quick Measure, Measure Totals, The Final Word should get you what you need:
https://community.powerbi.com/t5/Quick-Measures-Gallery/Measure-Totals-The-Final-Word/m-p/547907

 

Otherwise, Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

// Don't use SUMMARIZE for calculating
// anything. Use it only for getting
// distinct combinations of values.
// This function is flawed and cannot be
// fixed by Microsoft.

Customer_Product_Count = // it's a table, not a measure
ADDCOLUMNS(
    VALUES( Accounts_Final[Customer_ID] ),
    "Product Count",
    	CALCULATE(
    		DISTINCTCOUNT( Accounts_Final[Sub_Product_ID] )
    	)
)

 

Best

D

Greg_Deckler
Community Champion
Community Champion

Maybe a measures total problem? This looks like a measure totals problem. Very common. See my post about it here: https://community.powerbi.com/t5/DAX-Commands-and-Tips/Dealing-with-Measure-Totals/td-p/63376

Also, this Quick Measure, Measure Totals, The Final Word should get you what you need:
https://community.powerbi.com/t5/Quick-Measures-Gallery/Measure-Totals-The-Final-Word/m-p/547907

 

Otherwise, Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.