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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
magnus_b
Advocate II
Advocate II

Get totalt order revenue for orders containing a specific product

Hi!

 

I have tried searching for solutions, but couldn't find one that worked for my specifc use case.

I have a table like this:

 

orderidorderlineidproductnameamount
98711Product A92
98712Product X25
15361Product B150
15362Product A97
71521Product X82
71522Product X51
61281Product A41
61282Product B25


I then want to create the following measures:

1. Total order revenue for all orders containing Product X - expected result is 92+25+82+51 = 250
2. Number of orders containing Product X - expected result is 2

3. Total order revenue for all orders except orders containing Product X - expected result is 150+97+41+25 = 313
4. Number of orders except orders containing Product X - expected result is 2

I appreciate any help!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

 

[Total] = SUM( T[Amount] )

[# Orders] = DISTINCTCOUNT( T[Order ID] )

// 1
[Total X] =
var OrdersWithX =
    calculatetable(
        distinct( T[Order ID] ),
        keepfilters (
            T[Product] = "Product X"
        )
    )
return
calculate(
    [Total],
    OrdersWithX
)

// 2
[# Orders X] =
CALCULATE(
    [# Orders],
    KEEPFILTERS(
        T[Product Name] = "Product X"
    )    
)

// 3
[Total ~X] = [Total] - [Total X]

// 4
[# Orders ~X] = [# Orders] - [# Orders X]

 

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

 

[Total] = SUM( T[Amount] )

[# Orders] = DISTINCTCOUNT( T[Order ID] )

// 1
[Total X] =
var OrdersWithX =
    calculatetable(
        distinct( T[Order ID] ),
        keepfilters (
            T[Product] = "Product X"
        )
    )
return
calculate(
    [Total],
    OrdersWithX
)

// 2
[# Orders X] =
CALCULATE(
    [# Orders],
    KEEPFILTERS(
        T[Product Name] = "Product X"
    )    
)

// 3
[Total ~X] = [Total] - [Total X]

// 4
[# Orders ~X] = [# Orders] - [# Orders X]

 

That worked like a charm! Thanks!

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.