Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin 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.
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
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.
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
Solved! Go to Solution.
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.
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.
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] )
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
72 | |
71 | |
55 | |
37 | |
31 |
User | Count |
---|---|
87 | |
62 | |
61 | |
49 | |
45 |