I have the following DAX code in a data model pivot in order to provide a calculated field for median amount based data that needs to be summed before taking the median.
The median needs to appear based on specific categories of data.
=MEDIANX (
SUMMARIZE (
Range,
Range[INCOME_RANGE], Range[EMPLOYEE], "AMOUNT",
SUM ( Range[AMOUNT] )
),
[AMOUNT]
)
The problem is that in columns that have an even number of summed values, MEDIANX is only grabbing the first value rather than taking the average of the two middle values as would be typical in the normal way of calculating median.
For example, I have 40 rows after the summarize does its thing and sums the amount field. Row 20 is 9,945 and row 21 is 10,783.50. A normal Excel median formula would average those middle two out of the 40 rows to bring back 10,364.25, however, MEDIANX is merely grabbing the first of the two middle values to return 9,945 without doing the extra work. No, I do not have blank values.
What is up with that?? is there a way to fix this problem in DAX since I cannot use the regular MEDIAN formula due to the too many arguments error? There has to be a way to get a true median in a pivot table based on multiple sorting criteria.
The median needs to appear based on specific categories of data.
=MEDIANX (
SUMMARIZE (
Range,
Range[INCOME_RANGE], Range[EMPLOYEE], "AMOUNT",
SUM ( Range[AMOUNT] )
),
[AMOUNT]
)
The problem is that in columns that have an even number of summed values, MEDIANX is only grabbing the first value rather than taking the average of the two middle values as would be typical in the normal way of calculating median.
For example, I have 40 rows after the summarize does its thing and sums the amount field. Row 20 is 9,945 and row 21 is 10,783.50. A normal Excel median formula would average those middle two out of the 40 rows to bring back 10,364.25, however, MEDIANX is merely grabbing the first of the two middle values to return 9,945 without doing the extra work. No, I do not have blank values.
What is up with that?? is there a way to fix this problem in DAX since I cannot use the regular MEDIAN formula due to the too many arguments error? There has to be a way to get a true median in a pivot table based on multiple sorting criteria.