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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
OSKEEER
Regular Visitor

Sum and average in a matrix - making blanks show as zero values and taken into consideration

Hello, I have a problem i've been struggling with all day today.


I have a matrix showing categorys of products and articles  below each category. These I have as rows in the matrix. In the columns I show week - week 6 and 7 in my screenshot below.

Week by week and for each category and column I want to show the SUM of all sales made. In the total (bold marked in the screenshot below) I want the average to show.

It works but there is a problem that I need your help with, and that is that 0-values doesnt get calculated in the average.
So for example I want this to show:

Week 1 sales - 10 pieces
Week 2 sales - 0 pieces
Week 3 sales -  5 pieces
Average should be 5             (10+0+5)/3

In my database file of sales the product only shows in the current week if its been sold, if it hasnt been sold it doesnt show up - I have a bigger database for all the articles there is which is the foundation of the products showing in the matrix.

Below is the formula i use and a screenshot.

AverageSales =
COALESCE(
AVERAGEX(
    SUMMARIZE(
        'SalesTable',
        'SalesTable'[Category],
        'SalesTable'[Color],
        'SalesTable'[Article],
        'SalesTable'[Week],
        "Volym", SUM('SalesTable'[Volume])
    ),
    [Volym]
)
,0
)

pbi help.png

Thanks in advance and kind regards

Oskar

1 ACCEPTED SOLUTION

Your sample data does not warrant a many-to-many relationship.  Do you want to provide different sample data?

 

lbendlin_0-1708396479579.png

 

View solution in original post

3 REPLIES 3
OSKEEER
Regular Visitor

Hello, thank you for the response. Ill try here to explain better with samples.


I have two tables connected with a many to many relationsship - where SKU-code is the part connecting the two tables.

Article/settings table

Product nameColorSKU-codeCategory
LampGreen1234Lamps
SofaBlue5623Sofas
Standing lampBlack3357Lamps
Small bed tableBrown7500Tables


Sales table

VolumeWeekSKU-codeArticle
321234Lamp
225623Sofa
633357Standing lamp
423357Standing lamp


I want to create a Matrix in Power BI showing the following as rows, and weeks should be columns:

Category
Article
Color

All products should sum up per week, and the totals should be the average over the weeks shown/filtered.
This is the expected result im looking for

CategoryWeek 2Week 3Total
Lamps3,533,25
  +Lamp301,5
  +Standing Lamp465
Sofas2011
  +Sofa201
Tables000
  +Small bed table000

 

Hope this clarifys things and help 🙂 Kind regards

Oskar

Your sample data does not warrant a many-to-many relationship.  Do you want to provide different sample data?

 

lbendlin_0-1708396479579.png

 

lbendlin
Super User
Super User

to report on things that are not there you need to use disconnected tables and cross joins.

 

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).

Do not include sensitive information or anything not related to the issue or question.

If you are unsure how to upload data please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...

Please show the expected outcome based on the sample data you provided.

Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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