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
Peavey
Helper II
Helper II

Matrix visual - add column for average

Hi,

 

Is there a way to add a column in a matrix with average values in addition to totals?

matrix_col_avg.JPG

 

Thanks, 

/A

2 ACCEPTED SOLUTIONS
Icey
Community Support
Community Support

Hi @Peavey ,

 

It means that you could change the default Total value in Matrix visual to any aggregation value you want. For example, change Total to Avg.

Measure =
IF (
    HASONEFILTER ( 'Table'[Index] ),
    SUM ( 'Table'[Value] ),
    AVERAGE ( 'Table'[Value] )
)

avg.PNG

avg2.PNG

 

 

Best Regards,

Icey

 

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

Icey
Community Support
Community Support

Hi @Peavey ,

 

Try this:

Measure =
IF (
    HASONEFILTER ( 'Table'[Index] ),
    SUM ( 'Table'[Value] ),
    AVERAGEX (
        SUMMARIZE (
            'Table',
            'Table'[Asset],
            'Table'[Index],
            "Sum_", SUM ( 'Table'[Value] )
        ),
        [Sum_]
    )
)

avg3.PNG

 

Best Regards,

Icey

 

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

10 REPLIES 10
amitchandak
Super User
Super User

@Peavey , I do not think so. But can change it Avg. Refer, if this can help

https://community.powerbi.com/t5/Desktop/AVG-instead-Total-in-matrix/td-p/327031

Thanks... but I really don't understand what they are doing here?

Are they making a new measure in a column?

 

/A

Icey
Community Support
Community Support

Hi @Peavey ,

 

It means that you could change the default Total value in Matrix visual to any aggregation value you want. For example, change Total to Avg.

Measure =
IF (
    HASONEFILTER ( 'Table'[Index] ),
    SUM ( 'Table'[Value] ),
    AVERAGE ( 'Table'[Value] )
)

avg.PNG

avg2.PNG

 

 

Best Regards,

Icey

 

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

Thanks, it works perfectly 🙂

 

Can you explain the formula for me please? 

I don't follow what happens here: 

IF (
    HASONEFILTER ( 'Table'[Index] ),
    SUM ( 'Table'[Value] ),
    AVERAGE ( 'Table'[Value] )
)

  

 

As it appears, it did not give me the needed solution 😞

The top visual has the average values (haven't changed the name Total to avg). 

The bottom visual has the original values.

 

The case is in column 2: There are two values here 1000 and 500. 

I need the values in the matrix to sum, and the last column to be average of the sum values in the matrix. I don't want the average of ALL values.

If that was understandable?

matrix_col_avg_2.JPG

Icey
Community Support
Community Support

Hi @Peavey ,

 

Try this:

Measure =
IF (
    HASONEFILTER ( 'Table'[Index] ),
    SUM ( 'Table'[Value] ),
    AVERAGEX (
        SUMMARIZE (
            'Table',
            'Table'[Asset],
            'Table'[Index],
            "Sum_", SUM ( 'Table'[Value] )
        ),
        [Sum_]
    )
)

avg3.PNG

 

Best Regards,

Icey

 

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

Hi @Icey ,

 

Could you send me the sample file? 

I didn't understand what 'Table'[Value] is?

 

Thanks

Icey
Community Support
Community Support

Hi @Peavey ,

 

The basic file is the same as that uploaded before, and the measure is changed.

 

 

Best Regards,

Icey

Icey
Community Support
Community Support

Hi @Peavey ,

 

HASONEFILTER returns TRUE when the number of directly filtered values on columnName is one; otherwise returns FALSEAnd HASONEVALUE could also be used in your scenario. Here is one post which explains the principle in more detail. 

In your scenario, one column is one filtered value. Total column in Matrix visaul contains more than one filtered values. Hope I explained clearly.

 

 

Best Regards,

Icey

Is it to avoid calculating the empty values into the average?

Why SUM IF=TRUE and AVERAGE IF=FALSE?

 

Thanks alot! 🙂

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.