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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
AndyDo
Frequent Visitor

Add an average column to a matrix visualization

Hi,

 

I have a matrix visualiazion used to display sales data based on item transactions. The matrix shows the data based on calendar months. 

 

For example, I have the following Fact Table with data about item transactions:

 

AndyDo_0-1728012322148.png

 

And then I have a simple calendar:

 

AndyDo_1-1728012349222.png

 

I'm using the following measure for the matrix:

 

 

Sales = IF(CALCULATE(SUM(FactTable[Quantity]), KEEPFILTERS(FactTable[Transaction Type] = "Sale" )) = 0, BLANK(), CALCULATE(SUM(FactTable[Quantity]), KEEPFILTERS(FactTable[TransactionType] = "Sales" )))

 

 

 

And my matrix looks like this:

 

AndyDo_5-1728012958280.png

 

 

with the following selections:

 

AndyDo_4-1728012895616.png

 

Item Number is from the FactTable. Month is from the CalendarTable. And Sales is the mesaure above. 

 

I have a date slicer that allows me to select specific months for viewing. For example, if I choose a date range from January to March, the matrix will display only those three months instead of all twelve.

 

My question is whether it's possible to add an average column that reflects the date slicer. For instance, if the slicer includes all twelve months, the average calculation should consider all twelve months. In this case, the average for the first row would be 1/12 = 0.083.

 

If the matrix only shows data for July and August, then the average for the first row would be calculated as 1/2 = 0.5.

 

AndyDo_3-1728012827624.png

 

Thank you!

 

1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hi @AndyDo ,

 

Do you want to present the total and the average value?

If it's just the average without doing a lot of changes you can create the following measure:

Matrix value = 
var _value =SUM('Table'[Value])
var _months = COUNTROWS(ALLSELECTED('Table'[month]))
Return
IF(ISINSCOPE('Table'[month]), _value,FORMAT( DIVIDE(_value, _months), "0.00"))

MFelix_0-1728051495910.png

If you want to have the total you can do this:

Matrix value = 
var _value =SUM('Table (3)'[Value])
var _months = COUNTROWS(ALLSELECTED('Table (3)'[month]))
Return
IF(ISINSCOPE('Table (3)'[month]), _value,FORMAT( _value ,"#,###") & " | " & FORMAT( DIVIDE(_value, _months), "0.00"))

MFelix_1-1728051605765.png

Be aware that there are other options were you can create an hibrid table that will get the values but the syntax is much more complex check this example:

https://community.fabric.microsoft.com/t5/Community-Blog/Creating-a-custom-or-hybrid-matrix-in-Power...

 

 


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

2 REPLIES 2
AndyDo
Frequent Visitor

Hi Felix,

 

That works really great, thank you! The second formula is what I was looking for.

 

The only problem I'm having is with the date filter slicer. I have a slicer like the below based on the 'Transaction Date' column, and if I change the slicer, it doesn't update the '_months' variable. 

AndyDo_0-1728059928911.png

 

If I use a slicer like the below, based on the 'Month' column, then it does update the '_months' variable.

 

AndyDo_1-1728060007866.png

 

But I would prefer the first slicer, based on the 'Transaction Date.' Do you know if its possible to make it work like this?

 

Thank you!

 

 

 

MFelix
Super User
Super User

Hi @AndyDo ,

 

Do you want to present the total and the average value?

If it's just the average without doing a lot of changes you can create the following measure:

Matrix value = 
var _value =SUM('Table'[Value])
var _months = COUNTROWS(ALLSELECTED('Table'[month]))
Return
IF(ISINSCOPE('Table'[month]), _value,FORMAT( DIVIDE(_value, _months), "0.00"))

MFelix_0-1728051495910.png

If you want to have the total you can do this:

Matrix value = 
var _value =SUM('Table (3)'[Value])
var _months = COUNTROWS(ALLSELECTED('Table (3)'[month]))
Return
IF(ISINSCOPE('Table (3)'[month]), _value,FORMAT( _value ,"#,###") & " | " & FORMAT( DIVIDE(_value, _months), "0.00"))

MFelix_1-1728051605765.png

Be aware that there are other options were you can create an hibrid table that will get the values but the syntax is much more complex check this example:

https://community.fabric.microsoft.com/t5/Community-Blog/Creating-a-custom-or-hybrid-matrix-in-Power...

 

 


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



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