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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount 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
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.