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
Anonymous
Not applicable

Creating a measure from two other measures

I have a table (Measures) that is composed entirely of measures that are all created from at least two tables. I need to create a new measure, that when used in a matrix, will only calculate when another measure is a non-zero. For example:

 

Measure1: Cost = sum(table1[cost]) + sum(table2[cost])

Measure 2: Plays = sum(table1[plays]) + sum(table2[plays])

Measure 3: Cost/Play = Divide ( Cost, Plays, 0), but only for items where Plays are > 0 (thus only using the cost for items where plays > 0). This result is needed for correct summing and calculation in a matrix grand total (matrix is split by country and publishers, so publishers without any plays should not be counted in the cost/play totals as well. 

 

I've tried various versions using SumX, Calculate, and Filter but haven't had any luck.  

5 REPLIES 5
Anonymous
Not applicable

Thank you @amitchandak  and @mahoneypat  for your suggestions - unfortunately neither seem to have worked. Please see the below matrtix. The actual outcome for cost/plays at the "USA" level ($0.62) should be the same as the "LinkedIn" level $(0.35). I am starting to suspect an issue with the summing and subtotaling (as cost/play for "programmatic should be $0, as no items with plays had any associated spend) but I could be wrong

 

image.png

Anonymous
Not applicable

For posterity's sake (and anyone that may care), I seem to have found a solution. 

 

I created a new measure (Vid_cost) that only sums the spend for items that have video views using Calculate, sumX, and IF:

 

vid_cost = calculate(sumx(SiteTable, if([Video Plays]>0, [Spend], BLANK())))
 
I can then adjust the Cost/Plays formula to calculate using the Vid_Cost measure, resulting in a correct total and subtotal at both the publisher and country level. 
v-xuding-msft
Community Support
Community Support

Hi @Anonymous ,

 

If it still doesn't work after trying the formulas, please share some sample data and expected output to us. We will understand clearly about your actual situations.

 

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
amitchandak
Super User
Super User

@Anonymous , Try 1st

Cost/Play = Divide ( calculate(Cost,filter(table2,[Play]>0)), Plays, 0)

 

Or Add your dimensions in place of the dim , dim name (Common display) to correct the row context

 

AverageX(summarize(Dim, Dim[Name], "_1",if([Play]>0,[Cost],blank()),"_2",[Play]),divide([_1],[_2]))

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
mahoneypat
Microsoft Employee
Microsoft Employee

Have you tried an expression like this?

 

NewMeasure = IF([plays]>0, DIVIDE([cost], [plays],0))

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


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.