Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Calculated Column in a slicer - Using between - Max value = max sum of number column

Hi,   I have a calc column that sums the duration. The data is filtered by week number in a slicer   When I apply my calc col to a slicer and set to between, the min value = 30 and max value = 6...
  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi Anonymous,

    You can create a variable to calculate the average based on current week group, then you can use it as condition to filter records to get min and max summary values:

    minValue =
    VAR _avg =
        CALCULATE (
            AVERAGE ( 'Table'[duration] ),
            ALLSELECTED ( 'Table' ),
            VALUES ( 'Table'[weeknum] )
        )
    RETURN
        SUMX ( FILTER ( ALLSELECTED ( 'Table' ), [duration] < _avg ), [duration] )
    
    maxValue =
    VAR _avg =
        CALCULATE (
            AVERAGE ( 'Table'[duration] ),
            ALLSELECTED ( 'Table' ),
            VALUES ( 'Table'[weeknum] )
        )
    RETURN
        SUMX ( FILTER ( ALLSELECTED ( 'Table' ), [duration] > _avg ), [duration] )

    Regards,

    Xiaoxin Sheng