Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Qotsa
Helper V
Helper V

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 = 60. This make sense as the smallest value of duration = 30 and max = 60.

I want the max value to be = max sum of duration for an empid based on the selected week number and the min value to be = the min sum of duration for an empid based on the selected week number.

In my sample data, if week =1 is slected in slicer then I want to see my duration slicer to show a min value = 120 (duration = 30 * 4 for emp id = 1) and max malue = 300 (duration = 60 * 5 for empid = 2)

 

Qotsa_0-1678787623284.png

 

1 ACCEPTED SOLUTION
v-shex-msft
Community Support
Community Support

Hi @Qotsa,

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

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

2 REPLIES 2
Qotsa
Helper V
Helper V

TY very much.

v-shex-msft
Community Support
Community Support

Hi @Qotsa,

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

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.