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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
CJLastimosa07
New Member

Getting sum of a column of distinct rows from a filtered table

Hi,

 

I have 3 Tables:


Account:

Account IDAccount Name
123456789Company A
234567891Company B



Employee

Account NameEmployee IDEmployee
Company AE001John
Company AE002James
Company BE003Will


Connections

Connection IDClient IDClientCategorySalesAccount NameEmployee IDEmployee
C0001BU0001Alpha11,000Company AE001John
CL002BU0001Alpha11,000Company AE002James
CL003BU0002Beta12,000Company AE002James
CL004BU0003Charlie23,000Company AE002James
CL005BU0004Delta14,000Company BE003Will
CL006BU005Echo23,000Company BE003Will


I want to add another column in the Accounts table called "Total Sales per Category 1 Clients".

The idea is to get the sum of the 'Sales' value for distinct 'Client IDs' for "Category 1" clients only.

So the result would be:

Account IDAccount NameTotal Sales per Category 1 Clients
123456789Company A3,000
234567891Company B4,000

 

Is this possible using DAX?

 

Thank you.

1 ACCEPTED SOLUTION

Create this measure :

 

Total Sales Measure = SUMX (VALUES(Connections[Client ID]),CALCULATE(MAX(Connections[Sales]),Connections[Category] = 1 ))

 

SachinNandanwar_0-1728521827704.png

 



Regards,
Sachin
Check out my Blog

View solution in original post

8 REPLIES 8
SachinNandanwar
Super User
Super User

Why is the Total for Company A 3000 ?

SachinNandanwar_1-1728516462199.png

Shouldnt it be 4000 ?

SachinNandanwar_0-1728516435893.png

SachinNandanwar_2-1728516502520.png

 

[Total Sales Measure]= CALCULATE(SUM(Connections[Sales]),Connections[Category]=1)


Regards,
Sachin
Check out my Blog

Hi Sachin,

 

It should only sum the sales for distinct clients of the company.

But what is the business rule to decide the value of Sales to be used in the calculation for a distinct client ?

Lets assume Clinet Alpha has 2 unique Sales value 

SachinNandanwar_0-1728518190238.png

Which one should be used 1000 or 2000 ?





Regards,
Sachin
Check out my Blog

It's a column from another table (Clients). It's just added in the Connections table via LOOKUPVALUE, so it's always the same for the same client.

Create this measure :

 

Total Sales Measure = SUMX (VALUES(Connections[Client ID]),CALCULATE(MAX(Connections[Sales]),Connections[Category] = 1 ))

 

SachinNandanwar_0-1728521827704.png

 



Regards,
Sachin
Check out my Blog

It worked!

Thank you very much!

Kedar_Pande
Super User
Super User

New calculated column

Total Sales per Category 1 Clients = 
SUMX(
FILTER(
Connections,
Connections[Category] = 1 &&
Connections[Account Name] = EARLIER(Account[Account Name])
),
DISTINCT(Connections[Client ID]),
Connections[Sales]
)

Ensure that your tables have the correct relationships set up:

- Account Table: Account ID should relate to Account Name in both the Employee and Connections tables.
- Connections Table: Account Name should relate to the Account table based on the Account Name field.


If this helped, a Kudos 👍 or a Solution mark would be awesome! 🎉


Cheers,


Kedar Pande


Connect on LinkedIn



Hi,

 

It's giving me this error:

Error 1.jpg

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

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.