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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
Anonymous
Not applicable

ALLEXCEPT within selection

Hi,

 

My apologies if this question has been put out there before, but I not been able to find one that solves my issue:

 
 
 
 

I have a dataset where I want to calculate the sum by Table1[Item] within the selection in my slicer. ALLEXCEPT would do the trick, had it not forced the calculation on to the whole data set, ignoring the scope of the slicer.

 

This formula gives me exactly the answer I want, so long as I dont narrow down the selection with my date slicer (selection = all data):

_AveragePricePerItem = CALCULATE(DIVIDE(SUM(Table1[Sales]);SUM(Table1[VolumeDelivered]));ALLEXCEPT(Table1;Table1[Item]))

 

If I choose a period in my slicer (Table1[Date]) the measure _AveragePricePerItem stays the same, since ALLEXCEPT ignore the slicer filter. I want the average prices per item to be calculated within the slicer context, by Table1[Item].

 

This formula respects the slicer filter, but does not group by item.
_AveragePriceAllRows = CALCULATE(DIVIDE(SUM(Table1[Sales]);SUM(Table1[VolumeDelivered]));ALLSELECTED(Table1))

 

So I guess what I'm after is some sort of hybrid between the two above. Any suggestions as to how I can achieve this?

 

Please let me know if I need to elaborate further.

Here's a sample of my data:

191126-1.PNG

BR Thomas

3 REPLIES 3
v-lionel-msft
Community Support
Community Support

Hi @Anonymous ,

// if you want a column, do it like this:
_AveragePrice_PerItem_PerDate = 
CALCULATE(
    DIVIDE(
        SUM(Sheet1[Sales]),
        SUM(Sheet1[VD]),
        BLANK()
    ),
    FILTER(
        Sheet1,
        Sheet1[Item] = EARLIER(Sheet1[Item]) && Sheet1[Date] = EARLIER(Sheet1[Date])
    )
)

d11.PNG

//if you want a measure, do like this
_AveragePrice = 
CALCULATE(
    DIVIDE(
        SUM(Sheet1[Sales]),
        SUM(Sheet1[VD])
    ),
    ALLSELECTED(Sheet1[Item], Sheet1[Date])
) 

d13.PNG

 

Best regards,
Lionel Chen

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Thank you @v-lionel-msft for your answer. In my case I need this to be a measure.

 

I realise I haven't been clear enough about the fact that the item is the given by row, not a slicer - sorry about that.

 

In the example below I have tried to illustrate my expected outcome. The price column is simply the sales divided by VolumeDelivered, simple as that. _AveragePriceAllRows on the other hand is supposed to show the average price on item 1 across all orders within the selected period.

 

For instance, all sales of item 1 in the selected period, divided by the delivered volume of item 1 in the selected period, regardless of order number or any other row context.

 

As shown below, the mentioned measure in the opening post gives me the expected result, but my problem is that as I narrow down the period with a slicer on the date, the average prices dont change. I want the average price to change correspondingly to the selected period (in the slicer), but still operating on an item level, not order level.

191127-1.PNG

(This table and its data is just a simplified example to illustrate my point)

Hi @Anonymous ,

 

//Create column
Column 3 = 
CALCULATE(
    DIVIDE(
        SUM([sales]),
        SUM([VD])
    ),
    ALLEXCEPT(
        Sheet14,
        Sheet14[item], Sheet14[Date]
    )
)

 

//Measure
Measure 3 = 
CALCULATE(
    AVERAGE([Column 3]),
    ALLSELECTED(Sheet14[Date])
)

 

Best regards,

Lionel Chen

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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