Forum Discussion
How to calculate average value with null values
- 8 years ago
Hey,
I used this DAX statement to create a "calculated column"
the average = var theTable = UNION( ROW("value",'Table1'[Column1]) ,ROW("value",'Table1'[Column2]) ,ROW("value",'Table1'[Column3]) ,ROW("value",'Table1'[Column4]) ) var theSum = 'Table1'[Column1] + 'Table1'[Column2] + 'Table1'[Column3] + 'Table1'[Column4] var theDivisor = COUNTROWS( FILTER( theTable ,[value] <> BLANK() ) ) return DIVIDE(theSum, theDivisor, BLANK())All the columns have a numeric data tape like decimal.
I create a table from the columns that have to be considered using UNION(ROW(...),...)
I create a simple sum from the values of in the columns that have to be considered
I count the non empty rows in the table.
Based on my sample data this will retrun these results:
Hopefully this is what you are looking for,
Regards,
Tom
Hey,
I used this DAX statement to create a "calculated column"
the average =
var theTable =
UNION(
ROW("value",'Table1'[Column1])
,ROW("value",'Table1'[Column2])
,ROW("value",'Table1'[Column3])
,ROW("value",'Table1'[Column4])
)
var theSum = 'Table1'[Column1] + 'Table1'[Column2] + 'Table1'[Column3] + 'Table1'[Column4]
var theDivisor =
COUNTROWS(
FILTER(
theTable
,[value] <> BLANK()
)
)
return DIVIDE(theSum, theDivisor, BLANK())
All the columns have a numeric data tape like decimal.
I create a table from the columns that have to be considered using UNION(ROW(...),...)
I create a simple sum from the values of in the columns that have to be considered
I count the non empty rows in the table.
Based on my sample data this will retrun these results:
Hopefully this is what you are looking for,
Regards,
Tom
- Anonymous8 years agoNot applicable
- Anonymous8 years agoNot applicable
Hi,
when i added "the average" calculated column into report, i validated data and feel it is coming incorrectly bcoz of getting disable of Don't summarize option.
Could you please help me on how to enable Don't summarize option under value field.
If you screenshot attached, will understand clearly. Thanks.
- Anonymous4 years agoNot applicable
Hello Tom
How can I apply that solution when i have a unique colum, with some nulls values, and I need the average (as a metric) of that unique colum? Thanks