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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

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
Anonymous
Not applicable

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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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