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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
MCornish
Responsive Resident
Responsive Resident

Finding an average order value where order contains X

Hi All

 

Got a brainteaser here. 

 

I have a report that looks at a subset of products. From this I can get all the usual stuff (value, qtys etc) however what I want to find is the average order value of orders that contain my subset but not limited to .

 

Not a very good explanation so here is what Ive got so far

 

Wrong.PNG

The total order value for order 123456 is correct because all it contains is Product X. However 258369 is wrong because its only looking at line 1, it should be £10 like below.

 

Correct.PNG

 

And because 147258 doesnt contain Product X its excluded. This makes the AOV £12.50

 

Hope you can help and I've explained it thoroughly enough

 

Cheers

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

Hi @MCornish ,

 

Hi @MCornish ,

 

You could create a column to set a flag.

Flag =
VAR a =
    ADDCOLUMNS (
        'Product',
        "c", IF ( CONTAINSSTRING ( "X", 'Product'[Product] ), 0, 1 )
    )
RETURN
    PRODUCTX (
        FILTER ( a, 'Product'[OrderNumber] = EARLIER ( 'Product'[OrderNumber] ) ),
        [c]
    )

Then create a measure to calculate average.

_AOV =
CALCULATE (
    SUMX ( FILTER ( 'Product', 'Product'[Flag] = 0 ), 'Product'[Value] )
        / CALCULATE (
            DISTINCTCOUNT ( 'Product'[OrderNumber] ),
            FILTER ( 'Product', 'Product'[Flag] = 0 )
        ),
    ALLSELECTED ( 'Product' )
)

Here is the result.

3-1.PNG

 

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.

View solution in original post

2 REPLIES 2
v-eachen-msft
Community Support
Community Support

Hi @MCornish ,

 

Hi @MCornish ,

 

You could create a column to set a flag.

Flag =
VAR a =
    ADDCOLUMNS (
        'Product',
        "c", IF ( CONTAINSSTRING ( "X", 'Product'[Product] ), 0, 1 )
    )
RETURN
    PRODUCTX (
        FILTER ( a, 'Product'[OrderNumber] = EARLIER ( 'Product'[OrderNumber] ) ),
        [c]
    )

Then create a measure to calculate average.

_AOV =
CALCULATE (
    SUMX ( FILTER ( 'Product', 'Product'[Flag] = 0 ), 'Product'[Value] )
        / CALCULATE (
            DISTINCTCOUNT ( 'Product'[OrderNumber] ),
            FILTER ( 'Product', 'Product'[Flag] = 0 )
        ),
    ALLSELECTED ( 'Product' )
)

Here is the result.

3-1.PNG

 

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.
MCornish
Responsive Resident
Responsive Resident

Think I may have got it, can anybody validate that i'm not doing something weird

 

AOV = 

VAR Orders = SUMMARIZECOLUMNS('Product Entries'[Order Number], "SalesValue", [Total Sales Value])
VAR AllOrders = INTERSECT( CALCULATETABLE( SUMMARIZECOLUMNS( 'Product Entries'[Order Number], "SalesValue", [Total Sales Value]), REMOVEFILTERS( 'Product Brand'[Brand Name] ) ), Orders )

RETURN

AVERAGEX( AllOrders, [SalesValue] )

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.