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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Syndicate_Admin
Administrator
Administrator

Poorly calculated average

Hello, I am new and it is my first post, I have a problem when calculating an average on the total of a matrix, to explain better I put capture.

I calculate the total sales of 2020 and 2019, difference and variance, so far all correct, I create an average measure of the total and as you can check the data are not correct,

I also show a graph in which the automatic calculation of the average comes out correctly, I guess I'm not doing the measurement well:

Average - AVERAGE(BI_CM[VALUE])
Then when I click the different options and filters that I have, the values vary, but the average is far from what should be its value.

promedio.png

In black it tells me that the average is 103 in 2020

promedio2.png

Thanks a lot.

1 ACCEPTED SOLUTION
Syndicate_Admin
Administrator
Administrator

@Aguirre

The first thing would be to create a calendar table ("New Table" under "Modeling" in the menu):

Calendario =
VAR _MinDate =
    MIN ( BI_CM[FECHA] )
VAR _MaxDate =
    MAX ( BI_CM[FECHA] )
RETURN
    ADDCOLUMNS (
        CALENDAR ( _MinDate, _MaxDate ),
        "MesNum", MONTH ( [Date] ),
        "Año", YEAR ( [Date] ),
        "Mes", FORMAT ( [Date], "MMM" )
    )

Once created, sort the "Month" column by the "MesNum" column.

Now create a relationship between the Calendar [Date] and BI_CM[DATE]

Use the fields in the calendar table in visuals, measurements, filters, etc...

For measurements:

Total 2020 = 
      CALCULATE([TOTAL], FILTER(Calendario, Calendario [Año] = 2020))


And for the average:

Promedio 2020 = 
     AVERAGEX(Calendario, [Total 2020])

View solution in original post

4 REPLIES 4
Syndicate_Admin
Administrator
Administrator

@Aguirre

The first thing would be to create a calendar table ("New Table" under "Modeling" in the menu):

Calendario =
VAR _MinDate =
    MIN ( BI_CM[FECHA] )
VAR _MaxDate =
    MAX ( BI_CM[FECHA] )
RETURN
    ADDCOLUMNS (
        CALENDAR ( _MinDate, _MaxDate ),
        "MesNum", MONTH ( [Date] ),
        "Año", YEAR ( [Date] ),
        "Mes", FORMAT ( [Date], "MMM" )
    )

Once created, sort the "Month" column by the "MesNum" column.

Now create a relationship between the Calendar [Date] and BI_CM[DATE]

Use the fields in the calendar table in visuals, measurements, filters, etc...

For measurements:

Total 2020 = 
      CALCULATE([TOTAL], FILTER(Calendario, Calendario [Año] = 2020))


And for the average:

Promedio 2020 = 
     AVERAGEX(Calendario, [Total 2020])

Perfect. Now if it goes perfectly. Thank you so much for the help.

a greeting.

promedioOK.png

Syndicate_Admin
Administrator
Administrator

@Aguirre

Can you show the data model and measurements you're using for totals?

Well, I currently only have one table that's all-inclusive, since I'm starting relatively recently, and I'm testing.

The measure I use to calculate the total for each total year is:

TOTAL = SUM(BI_CM[VALOR])
Total 2020 = CALCULATE([TOTAL], BI_CM[ANNO]=2020)

datos.png

thank you for the help

A greeting

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors
Top Kudoed Authors