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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
cheid_4838
Helper IV
Helper IV

Creating a measure that inserts both average and total in matrix?

I have a matrix table that calculates various parameters and then averages them out (below).  I would like to create a measure that will put both the average and total for the date range shown.  Is it possible with the measure below to do this?  Thanks.

 

Total Charges - AVERAGE FOR WEEKLY MATRIX =
AVERAGEX(VALUES('Lookup Calendar'[End of Week]), [Total Charges])

 

cheid_4838_0-1760703068971.png

 

3 REPLIES 3
V-yubandi-msft
Community Support
Community Support

Hi @cheid_4838 ,

Both solutions from @Ritaf1983  and @johnbasha33  are correct, they simply use different approaches based on how you want your totals displayed.

1. If you want separate Total and Average columns, Yugi’s two-measure method is ideal.

2. If you prefer showing Sum and Average as extra rows, Mahi’s approach works well.

Either option is valid and will give you accurate results, so it depends on whether you want columns or summary rows.

Thank you both, @Ritaf1983  and @johnbasha33 , for your helpful input.

If you need more details, please let us know.

Ritaf1983
Super User
Super User

Hi @cheid_4838 

Unfortunately, Power BI does not support showing two types of totals (e.g. sum and average) in a matrix visual.

As a workaround, you can create a custom dates table that includes both the regular dates and additional rows for "Sum" and "Average" – like shown in the image.

Ritaf1983_0-1760710398271.png

 

Since the "Sum" and "Average" values are text, the whole column becomes text. To keep the correct sorting, you should add an index column.

Ritaf1983_1-1760710438092.png

 

In the fact table, duplicate the date column and change the data type to text so it can be used to link with the new dates table.

Ritaf1983_2-1760710486036.png

 

Create a relationship between the two tables using the text date columns – set this relationship as inactive.

Ritaf1983_3-1760710516987.png

 

Then, use a DAX measure like this to handle the logic for regular dates vs. "Sum" and "Average":

Measure_ =
if (SELECTEDVALUE('Dates with totals'[End of week (Sat.)]) IN {"Sum","Average"},
IF(SELECTEDVALUE('Dates with totals'[End of week (Sat.)]) = "Sum",
SUM('Data table'[Value]),
IF(SELECTEDVALUE('Dates with totals'[End of week (Sat.)]) = "Average",
AVERAGE('Data table'[Value]))),
CALCULATE(
SUM('Data table'[Value]),
USERELATIONSHIP('Data table'[End of week (Sat.) - Copy],'Dates with totals'[End of week (Sat.)])
))

Since the native matrix visual doesn’t support customizing total rows like in the Totals card, you can use conditional formatting to highlight the "Sum" and "Average" rows with a background color.

Example:

color = IF(SELECTEDVALUE('Dates with totals'[End of week (Sat.)]) IN {"Sum","Average"}, "#F2F2F2")

Apply this as a background color with conditional formatting.

Result :

Ritaf1983_4-1760710598446.png

The pbix is attached

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

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile
johnbasha33
Super User
Super User

Hi @cheid_4838 
you can show both the weekly average and the total for the visible date range. Do it with two measures (and, if you want them side-by-side in the matrix, add a tiny “Metric” slicer/switch). Here’s the DAX you need:
Base measure (you likely already have)
Total Charges :=
-- your existing total measure
SUM('Fact'[ChargeAmount]) -- example only

Total for the current visible date range (ignores the week row in the matrix)
Total Charges – Date Range Total :=
CALCULATE(
[Total Charges],
ALLSELECTED('Lookup Calendar'[End of Week])
)

Weekly average over the visible weeks

(averages only weeks that actually have a value; include zero-weeks by wrapping with COALESCE([Total Charges], 0) inside AVERAGEX)

Total Charges – Weekly Average (Date Range) :=
VAR WeeksInScope :=
FILTER(
ALLSELECTED('Lookup Calendar'[End of Week]),
NOT ISBLANK( CALCULATE([Total Charges]) )
)
RETURN
AVERAGEX(WeeksInScope, CALCULATE([Total Charges]))

Use these two measures directly in your matrix if you’re OK having two value columns.

Did I answer your question? Mark my post as a solution! Appreciate your Kudos !!











Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 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.