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
Pearlsia
Frequent Visitor

Average of Measures excluding those with blank value

Hi, 

How do I put this in DAX without having too many IFs:

I have measures like as follows:
Measure Name      Values
Measure1                 1
Measure2                 2
Measure3                 1
Measure4                 
Measure5                 0

I need to be able to get the Average which should be like below:

([Measure1] + [Measure2]+ [Measure3]  +[Measure5])/4

Denominator is 4 because we have blank for Measure4 hence excluding it.

 

And any of the measure may be blank.

Another scenario:
Measure Name      Values
Measure1                 
Measure2                 2
Measure3                 1
Measure4                 
Measure5                 0

I need to be able to get the Average which should be like below:

([Measure2] + [Measure3]+ [Measure5])/4

 

 

Problem is I cannot use AVERAGE function for this.

 

Please help and much appreciated.

🙂

1 ACCEPTED SOLUTION
Vvelarde
Community Champion
Community Champion

@Pearlsia

 

Hi, using a measure with IF :

 

 

CountMeasuresNoBlank =
      IF ( [Measure1] <> BLANK (); 1 )
    + IF ( [Measure2] <> BLANK (), 1 )
    + IF ( [Measure3] <> BLANK (), 1 )
    + IF ( [Measure4] <> BLANK (), 1 )

 

 

MeasureSum = [Measure1]+[Measure2]+[Measure3]+[Measure4] 
AvgMeasures = DIVIDE([MeasureSum],[CountMeasuresNoBlank])

Regards

 

Victor

Lima - Peru

 

 

 




Lima - Peru

View solution in original post

3 REPLIES 3
Vvelarde
Community Champion
Community Champion

@Pearlsia

 

Hi, using a measure with IF :

 

 

CountMeasuresNoBlank =
      IF ( [Measure1] <> BLANK (); 1 )
    + IF ( [Measure2] <> BLANK (), 1 )
    + IF ( [Measure3] <> BLANK (), 1 )
    + IF ( [Measure4] <> BLANK (), 1 )

 

 

MeasureSum = [Measure1]+[Measure2]+[Measure3]+[Measure4] 
AvgMeasures = DIVIDE([MeasureSum],[CountMeasuresNoBlank])

Regards

 

Victor

Lima - Peru

 

 

 




Lima - Peru

Hi @Vvelarde,

 

Thank you heap Smiley Very Happys. With your help I was able to get the correct measure to get the average. I basically just edit my measure names and put them in variables. The CountMeasuresNoBlank is a winner! Thanks!

ScoreOverall = VAR SumScores = ([Score1]+[Score2]+[Score3]+[Score4]+[Score5)
					
	       VAR CountMeasuresNoBlank =
			IF ( [Score1] <> BLANK (), 1 )
			+ IF ( [Score2] <> BLANK (), 1 )
			+ IF ( [Score3] <> BLANK (), 1 )
			+ IF ( [Score4] <> BLANK (), 1 
			+ IF ( [Score5] <> BLANK (), 1 )) + 1
																		
	RETURN
		ROUND(DIVIDE(SumScores,CountMeasuresNoBlank),1)

@Vvelarde 

v-sihou-msft
Microsoft Employee
Microsoft Employee

@Pearlsia

 

In your scenario, the values are the result from measures. It's not possible to count number of measures (as your denominator) based on their results. 

 

Regards,

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

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

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.