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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Evandam
Helper II
Helper II

combine groupby with sum

hi,

 

I could realy use your help on this one 🙂

I have two tables, both containing a key wich i could use to match rows of the two tables.

But, this would be a many to many realtion because in both table the key is present more than 1 time.

 

what i to compute is the total sales amount by key from table A, and then also compute the total sales amount by key of table B.

for table A i have used groupby. But now i would like to add a column in which the sum of sales by key from table B is shown. That way i can compare "Amount_By_Key" with "SAM sum of sales" per "key".

Basically i want to compare the total sales amount by key in table A with table B. 

NOTE: some keys that excist in table A dont appear in table B. 

Evandam_0-1658829506069.png

 

please find attached the data: OneDrive data 

1 ACCEPTED SOLUTION

@Evandam 
Are you sure there is a relationship between the twoo tables? If not you can use

SAM sum of sales =
SUMX (
    FILTER (
        'SAM Facturatieregels',
        'SAM Facturatieregels'[Overeenkomstnummer] = 'CBA by key'[Key]
    ),
    'SAM Facturatieregels'[Factuurbedrag in valuta]
)

View solution in original post

7 REPLIES 7
tamerj1
Super User
Super User

Hi @Evandam 

Please use 

SAM sum of sales =
SUMX (
    RELATEDTABLE ( 'SAM Facturatieregels' ),
    'SAM Facturatieregels'[Overeenkomstnummer]
)

hi @tamerj1 ,

thanks for the reply. When i try to do that i get an exception: 

Evandam_0-1658835016517.png

the key contains numeric values combined with text values
any other suggestion?

@Evandam 
I thought this is the column that you want to sum. What is the name of that column?

@tamerj1 

i want to sum 'SAM Facturatieregels' [Factuurbedrag in valuta] by key.
when i try to do this i get: 

Evandam_0-1658835423898.png

please have a look in the excel file (One drive) tab "result".

that exact outcome i would like to build in PowerBI

 



@Evandam 
Then use

SAM sum of sales =
SUMX (
    RELATEDTABLE ( 'SAM Facturatieregels' ),
    'SAM Facturatieregels'[Factuurbedrag in valuta]
)

Evandam_0-1658836412810.png

 

already did so (see my reply before this message).
the outcome is not satisfying as you can see. 

 

@Evandam 
Are you sure there is a relationship between the twoo tables? If not you can use

SAM sum of sales =
SUMX (
    FILTER (
        'SAM Facturatieregels',
        'SAM Facturatieregels'[Overeenkomstnummer] = 'CBA by key'[Key]
    ),
    'SAM Facturatieregels'[Factuurbedrag in valuta]
)

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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