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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
abertolett
Frequent Visitor

CALCULATING an AVG Measure for category segment

 Having a hard time calculating an AVG just for records where they share another column's value (e.g. same category).

 

Here's a simplification of the model:

 

 

sports1.jpg

 

 

 

 

AOV is simply Rev/Orders

 

Here's the measure I tried:

Category AOV= CALCULATE(SUM(Table B[Revenue]) / SUM('Table A'[Orders]), ALLEXCEPT('Table A','Table A'[Orders]))

 

What's strange is that it seemed to work where "Category AOV" was matching category. Then I changed a visualization and then every "Category AOV" was the same value.

 

Obviously there's something I'm missing about how Measures interact with filtering.

 

 

 

 

 

1 ACCEPTED SOLUTION
v-sihou-msft
Employee
Employee

@abertolett

 

In this scenario, since you want to calculate the AOV by Category, you should put Category column in ALLEXCEPT() to have your calculation group on this column.

 

AOV = CALCULATE(SUM(TableB[Rev])/SUM(TableA[Orders]),ALLEXCEPT(TableA,TableA[Category]))

8.PNG

 

 

Regards,

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

@abertolett

An other way is to change the context by using this formula: grafik.png

Category AOV = 
CALCULATE(
	sum('Table B'[Revenue]);
	ALL('Table A'[Name])) 
	/ 
CALCULATE(
	sum('Table A'[Orders]);
		All('Table A'[Name]) 
		)
v-sihou-msft
Employee
Employee

@abertolett

 

In this scenario, since you want to calculate the AOV by Category, you should put Category column in ALLEXCEPT() to have your calculation group on this column.

 

AOV = CALCULATE(SUM(TableB[Rev])/SUM(TableA[Orders]),ALLEXCEPT(TableA,TableA[Category]))

8.PNG

 

 

Regards,

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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