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
ICRdatalover
Advocate I
Advocate I

Matrix subtotal excluding "0" values?

Hi everyone, 

 

I know there are severals post with similar doubts but no one is suitable for my problem.

 

I have a Matrix-table like below wich is showing the average in the subtotals rows, what I would like to know what is the DAX formula to exclude the "0,00s" values from this subtotal-average, but not with a filter excluding the "number 5" because today number 5 doesnt have values but it will have them in a close future.

 

bad subtotal.PNG

 

 

 

 

 

 

 

 

 

 

 

 

Are there any way to do that? There are similar problems on the forum but not the same.

 

Any help will be really appreciate it.

 

Thank you in advance.

 

Kind regards

 

ICR

1 ACCEPTED SOLUTION

Hi @ICRdatalover ,

 

Please download a demo from the attachment. 

1. If you don't want to transform your data, you can create 7 measures like below.

Value1Measure =
CALCULATE ( AVERAGE ( 'Sample'[value1] ), 'Sample'[value1] <> 0 )

2. I would suggest you transform the data structure. 

Measure =
CALCULATE ( AVERAGE ( Table1[Value] ), Table1[Value] <> 0 )

Matrix-subtotal-excluding-0-values

 

Best Regards,

Community Support Team _ Dale
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
ICRdatalover
Advocate I
Advocate I

Hi @PattemManohar!

 

Thank you for taking the time to help me.

 

The problem is that its and AVERAGE, when you do the SUM like you solution it works fine, because its a "0",  but when you do it with average the total do the average with the "0" values, what Im struggling is trying to exclude this "0" from the average but showing it , not excluding it on a filter.

 

Im not sure if im explaining it properly, here is a pic of what happend with the average

 

Captura.PNG

Thank you for your help!

 

 

ICR

@ICRdatalover  Ok Gotcha !!

 

Please try this as a New Measure.

 

Test236 = 
VAR _CountRows = COUNTROWS(FILTER(Test236MatrixZeroExclusion,Test236MatrixZeroExclusion[Value]>0))
VAR _Sum = SUM(Test236MatrixZeroExclusion[Value])
VAR _TotalAvg = _Sum/_CountRows
RETURN IF(_Sum=0,0,_TotalAvg)

image.png





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

Proud to be a PBI Community Champion




Hi @PattemManohar!!

 

Now It looks exacly what I need, thanks a lot.

 

But how should I fit this measure in the table? My table just have "Rank" on rows and "Value1", "Value2", etc on values.

 

Something is wrong and there is an error like the image

12.PNG

Could you please share the .pbix ?Maybe I will understand it better. Thanks a lot Pattem!

 

Kind regards.

 

ICR

@ICRdatalover I can't see that you have mentioned any Columns field in the screenshot... 

 

image.png





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

Proud to be a PBI Community Champion




Hi @PattemManohar!

 

Yes, probably thas the issue why your solutions doesnt work for me, I didnt add any columns, just Rows and Values in the Matrix Table.

13.PNG

 

How should I change the measure to fit it in this table? 

 

Thank you in advance.

 

Kind regards

 

ICR.

@ICRdatalover  Is it your table structure is aligned with the structure of sample input data that I've posted above ? If not, could you please post the sample data 





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

Proud to be a PBI Community Champion




Yes sure!, here is the sample.

 

https://drive.google.com/open?id=1YaQvsWoE3HI4PjStnRu8V1AOMhs96gn_

 

I think my table was diferent than yours.

 

Kind regards

 

 

Hi @ICRdatalover ,

 

Please download a demo from the attachment. 

1. If you don't want to transform your data, you can create 7 measures like below.

Value1Measure =
CALCULATE ( AVERAGE ( 'Sample'[value1] ), 'Sample'[value1] <> 0 )

2. I would suggest you transform the data structure. 

Measure =
CALCULATE ( AVERAGE ( Table1[Value] ), Table1[Value] <> 0 )

Matrix-subtotal-excluding-0-values

 

Best Regards,

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

Hello!

 

That is exacly what I needed, problem solved! Also I will change the structure as well to use the second way.

 

Thanks a lot for taking the time to help me @v-jiascu-msft and @PattemManohar!!

 

Kind regards.

 

ICR:

PattemManohar
Community Champion
Community Champion

@ICRdatalover  Please try as below

 

Sample Input DataSample Input Data

Default Matrix BehaviourDefault Matrix BehaviourExcluded Zero values from the MatrixExcluded Zero values from the Matrix





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

Proud to be a PBI Community Champion




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.