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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Need to create a measure based on values from 2 tables and grouping

Power BI Experts, Please help as I need to create a column chart based on the amount of product sold minus amount of products returned. Suppose I have 2 tables Sales and Return as mentioned below. Now I need to  draw a column chart showing net sales (Sales-return) of products. Product name on x axis and sum of amount(sales - return) on y axis.

Sales Table

Product  Amount

A               5

B               4

A               3

C               4

B               3

B               4

C               5

Return Table

Product        Amount

A                     3

A                     1

B                      2

B                      1

C                     1

1 ACCEPTED SOLUTION
Anonymous
Not applicable

This can be solved with basic data modeling.  You need a common dimension table for Products.  This should be a DISTINCT list of every Product Code (A, B, C, etc.)

 

Then you create a  One-to-Many relationship betwheen the Products table and both the Sales and Returns tables.

 

Use the Product table's Product Code column in the chart

 

then make 3 measures

 

[# Sales] = SUM( Sales[Amount] )
[# Returns] = SUM( Returns[Amount] )
[# Net Sales] = [# Sales] - [# Returns]

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

This can be solved with basic data modeling.  You need a common dimension table for Products.  This should be a DISTINCT list of every Product Code (A, B, C, etc.)

 

Then you create a  One-to-Many relationship betwheen the Products table and both the Sales and Returns tables.

 

Use the Product table's Product Code column in the chart

 

then make 3 measures

 

[# Sales] = SUM( Sales[Amount] )
[# Returns] = SUM( Returns[Amount] )
[# Net Sales] = [# Sales] - [# Returns]

Better to use variables :

MyMeasure = 
var vAmount = SUM( Sales[Amount] )
var vReturn = SUM( Returns[Amount] )
return
[# Net Sales] = vAmount  - vReturn 

in this case, you'll see only the finale measure into your dataset

Anonymous
Not applicable

thanks Chris. It works.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors
Top Kudoed Authors