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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
ki
Frequent Visitor

Creating a Measure Based on 2 Tables

Hello,

 

Trying to create a measure that shows revenue for specific product category as percentage of total revenue. Below are the 2 tales. This is of course easily achievable by creating a relationship b/n those and then creating a visual. Yet, I need it is a measure 😞 Want to avoid long coding as the real data is bigger/complex (e.g. I can combine filter and sumx in Table 1 given that I know the category of each product) and want to avoid joining tables.

 

Category A = 43% of Total Revenue

 

ki_0-1616508429934.png

 

ki_1-1616508453925.png

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @ki ,

 

So category A should be 12/(12+6+23+12+45+12) = 10.9%? If so, you will need to modify the measure as below.

Measure = 
var total_rev = CALCULATE(SUM(Table1[revenue]),ALL(Table1))
var pro_rev = CALCULATE(SUM(Table1[revenue]),FILTER(ALL(Table1),Table1[product] in VALUES(Table2[product])))
return
pro_rev/total_rev

 

Best Regards,

Jay

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Hi @ki ,

 

Check the measure.

Measure = 
var avg_rev = CALCULATE(SUM(Table1[revenue]),ALL(Table1))/CALCULATE(DISTINCTCOUNT(Table2[category]),ALL(Table2))
var pro_rev = CALCULATE(SUM(Table1[revenue]),FILTER(ALL(Table1),Table1[product] in VALUES(Table2[product])))
return
pro_rev/avg_rev

1.PNG

You said "Category A = 43% of Total Revenue", I assumed that you mean avg of revenue? Otherwise I don't know how to get 43% for Category A.

 

Best Regards,

Jay

ki
Frequent Visitor

Thanks, the 43% wasj ust an example of what I want to get.

Anonymous
Not applicable

Hi @ki ,

 

So category A should be 12/(12+6+23+12+45+12) = 10.9%? If so, you will need to modify the measure as below.

Measure = 
var total_rev = CALCULATE(SUM(Table1[revenue]),ALL(Table1))
var pro_rev = CALCULATE(SUM(Table1[revenue]),FILTER(ALL(Table1),Table1[product] in VALUES(Table2[product])))
return
pro_rev/total_rev

 

Best Regards,

Jay

amitchandak
Super User
Super User

@ki , assume revenue is a measure , both tables are joined  on product and you are using product and product category from product table in visual

 

calculate(divide([revenue], calculate([revenue], filter(allselected(product), product[product category] = max(product[product category] )))))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Wow, that was fast! But I am not sure I get it... The divide function is clear. What I dont' get is the second calculate - this pretty much should filter on a specific category. How would it look for let's say building this measure for Category A? I tried different syntax, but I get different errors...

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 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.