I am having an issue that I am hoping some more experienced DAX programmers may be able to help me with. This problem is cross-posted on StackOverflow here (excel - Medians and slicers in DAX - Stack Overflow) with no answers so far.
I have been trying to develop a dashboard in Excel 2013 / PowerPivot / PowerView and one of the graphics I would like to display is a line chart of median performance by hour of day. I would then like to filter the data set with my performance metrics based on a separate field, and link that to a slicer. The medians should be calculated relative to the filtered data set. For the median calculation I am trying to adapt the formula proposed by Marco Russo here (SQLBI - Marco Russo : Median calculation in DAX).
To illustrate the problem, suppose that I have two tables - main_table and other_table. Main_table has 4 fields - RowID, hour_of_day, performance_metric, and category. Other_table has two fields - hour_of_day and median_field. My goal is to find a formula for median_field such that it shows the median performance metric by hour of day, but can still be sliced by category. The formula I tried to use for the medians was
However, when I create a slicer based on category in main_table, my chart does not seem affected by the slicer. My understanding was that by putting main_table as opposed to ALL(main_table) as the first argument in the last FILTER call, my median calculations would be subject to slices and filters applied to main_table. Am I missing something obvious here?
I have been trying to develop a dashboard in Excel 2013 / PowerPivot / PowerView and one of the graphics I would like to display is a line chart of median performance by hour of day. I would then like to filter the data set with my performance metrics based on a separate field, and link that to a slicer. The medians should be calculated relative to the filtered data set. For the median calculation I am trying to adapt the formula proposed by Marco Russo here (SQLBI - Marco Russo : Median calculation in DAX).
To illustrate the problem, suppose that I have two tables - main_table and other_table. Main_table has 4 fields - RowID, hour_of_day, performance_metric, and category. Other_table has two fields - hour_of_day and median_field. My goal is to find a formula for median_field such that it shows the median performance metric by hour of day, but can still be sliced by category. The formula I tried to use for the medians was
Code:
<code>=CALCULATE(MINX(FILTER(VALUES(main_table[performance_metric]), CALCULATE(COUNTA(main_table[performance_metric]), main_table[performance_metric] <= EARLIER(main_table[performance_metric])) > COUNTA(main_table[performance_metric]/2), main_table[performance_metric]), FILTER(main_table, main_table[hour_of_day] = EARLIER(other_table[hour_of_day]))) </code>
However, when I create a slicer based on category in main_table, my chart does not seem affected by the slicer. My understanding was that by putting main_table as opposed to ALL(main_table) as the first argument in the last FILTER call, my median calculations would be subject to slices and filters applied to main_table. Am I missing something obvious here?