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
JJ2022PBI
Helper I
Helper I

Sales less average sales per category

Hi,

 

Probably a simple one but I can't figure out how to do this.

 

I have the below data and I want to create a table which shows the variance in total sales for a product to that of the average of that category. In the below I have calcualted the total sales by products marked as a rating of 5 (3,350), then divided this by the amount of products in this category (3) to get the average of 1,117.

 

In my visualisation I then show the total sales by product next to average for that category and then a variance.

 

Thanks!

 

 

JJ2022PBI_0-1669062724425.png

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @JJ2022PBI ,

 

Here are the steps you can follow:

1. Create measure.

Flag =
 IF(
     MAX('Fact Table'[Product])<>"C",1,0)
Total Sales =
SUMX(FILTER(ALL('Fact Table'),
'Fact Table'[Product]=MAX('Fact Table'[Product])
),[Sales])
Average for category =
var _sum =
SUMX(ALLSELECTED('Fact Table'),
[Sales])
var _count=
CALCULATE(DISTINCTCOUNT('Fact Table'[Product]),
ALLSELECTED('Fact Table'))
return
DIVIDE(_sum,_count)
Variance =
[Total Sales] - [Average for category]

2. Place [Flag]in Filters, set is=1, apply filter.

vyangliumsft_0-1669080802271.png

3. Result:

vyangliumsft_1-1669080802276.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi  @JJ2022PBI ,

 

Here are the steps you can follow:

1. Create measure.

Flag =
 IF(
     MAX('Fact Table'[Product])<>"C",1,0)
Total Sales =
SUMX(FILTER(ALL('Fact Table'),
'Fact Table'[Product]=MAX('Fact Table'[Product])
),[Sales])
Average for category =
var _sum =
SUMX(ALLSELECTED('Fact Table'),
[Sales])
var _count=
CALCULATE(DISTINCTCOUNT('Fact Table'[Product]),
ALLSELECTED('Fact Table'))
return
DIVIDE(_sum,_count)
Variance =
[Total Sales] - [Average for category]

2. Place [Flag]in Filters, set is=1, apply filter.

vyangliumsft_0-1669080802271.png

3. Result:

vyangliumsft_1-1669080802276.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

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.