Forum Discussion
Average for first two non blank values
- 6 years ago
Hi Anonymous ,
We can use the following measure to meet your requirement.
Measure = VAR min_date = CALCULATE ( MIN ( 'Table'[Month Value] ), FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Name] = MAX ( 'Table'[Name] ) && 'Table'[Value] <> BLANK () ) ) VAR _firstMonth = CALCULATE ( MAX ( 'Table'[Month] ), FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Month Value] = min_date && 'Table'[Name] = MAX ( 'Table'[Name] ) ) ) VAR _secondMonth = CALCULATE ( MAX ( 'Table'[Month] ), FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Month Value] = min_date + 1 && 'Table'[Name] = MAX ( 'Table'[Name] ) ) ) VAR first_value = CALCULATE ( SUM ( 'Table'[Value] ), ALLEXCEPT ( 'Table', 'Table'[Name] ), 'Table'[Month] = _firstMonth ) VAR second_value = CALCULATE ( SUM ( 'Table'[Value] ), ALLEXCEPT ( 'Table', 'Table'[Name] ), 'Table'[Month] = _secondMonth ) RETURN DIVIDE ( first_value + second_value, 2 )The result like this,
If you want the result like your desire result table, please refer the following steps.
1. Create a table that contains the matrix column’s name.
2. Then we can create a measure to calculate the value of each month.
values = CALCULATE(SUM('Table'[Value]),FILTER('Table','Table'[Month]=MAX('Table (2)'[Column])))3. At last we can create a measure to get the desire result.
Noblank_two_Month = SUMX ( VALUES ( 'Table (2)'[Column] ), SWITCH ( 'Table (2)'[Column], "Jan", [values], "Feb", [values], "Mar",[values], "Apr",[values], "May",[values], "Noblank_two_Month",[Measure] ) )If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?
BTW, pbix as attached.
Best regards,
Community Support Team _ zhenbw
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous What does the measure calculation look like and how does the raw data table look? I agree that variables can help here, but need more info from you to provide more detailed, helpful response.