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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
simonm8008
Frequent Visitor

Help needed: ALLSELECTED with the exception of one column

Fairly new at this, so there's probably a simple solution for my problem.

 

I have the following table where I am calculating an average of the last 5 sprints

 

Average last 5 sprints.png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

I am using the following measure:

Average Velocity Last 5 Sprints = 
VAR MaxSprint = SELECTEDVALUE('All User Stories'[Sprint ID])
VAR SprintRange = MaxSprint - 4
RETURN
CALCULATE(
    AVERAGEX('All User Stories',SUM('All User Stories'[Story Points])),
    FILTER(ALLSELECTED('All User Stories'),
        'All User Stories'[Sprint ID] >= SprintRange && 'All User Stories'[Sprint ID] <=MaxSprint)
        )

However, what I actually want to do is to keep all filters EXCEPT for 'ADMS All User Stories'[Sprint ID].

Any help would be greatly appreciated!

4 REPLIES 4
v-yetao1-msft
Community Support
Community Support

Hi @simonm8008 

Did you get the result you want ? If yes , please consider Accept it as the solution to help the other members find it more quickly.

 

Best Regards,
Community Support Team _ Ailsa Tao

AlexisOlson
Super User
Super User

You've got an odd mix of things going on here.

 

I'd recommend re-writing your measure like this:

Average Velocity Last 5 Sprints =
VAR MaxSprint = SELECTEDVALUE ( 'All User Stories'[Sprint ID] )
VAR SprintRange = MaxSprint - 4
RETURN
    CALCULATE (
        AVERAGE ( 'All User Stories'[Story Points] ),
        ALLSELECTED ( 'All User Stories' ),
        'All User Stories'[Sprint ID] >= SprintRange,
        'All User Stories'[Sprint ID] <= MaxSprint
    )

Or like this:

Average Velocity Last 5 Sprints =
VAR MaxSprint = SELECTEDVALUE ( 'All User Stories'[Sprint ID] )
VAR SprintRange = MaxSprint - 4
RETURN
    AVERAGEX (
        FILTER (
            ALLSELECTED ( 'All User Stories' ),
            'All User Stories'[Sprint ID] >= SprintRange &&
            'All User Stories'[Sprint ID] <= MaxSprint
        ),
        'All User Stories'[Story Points]
    )

 

I think the main problem you have is that the SUM inside AVERAGEX isn't transforming the row context of the iterator into filter context.

Shaurya
Memorable Member
Memorable Member

Hi @simonm8008,

 

Use:

 

Average Velocity Last 5 Sprints = 
VAR MaxSprint = SELECTEDVALUE('All User Stories'[Sprint ID])
VAR SprintRange = MaxSprint - 4
RETURN
CALCULATE(
AVERAGEX('All User Stories',SUM('All User Stories'[Story Points])),
FILTER(ALLEXCEPT('ADMS All User Stories'[Sprint ID]),
'All User Stories'[Sprint ID] >= SprintRange && 'All User Stories'[Sprint ID] <=MaxSprint))

 

Works for you? Mark this post as a solution if it does!
Consider taking a look at my blog: Forecast Period - Previous Forecasts

ALLEXCEPT does the opposite of what OP is asking for (and requires a table for the first argument).

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.

Top Solution Authors