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
Evan4
Frequent Visitor

Calculating total value of invoices where certain Product ID's exist

Hello!

 

I have a question that I haven’t been able to figure out nor find an answer to on the internet… so I thought I could ask here and someone may have an answer for me!

 

I need to calculate the total value of all invoices that contain certain Product ID’s.

 

Note: Just in case someone jumps the gun, I know how to use the calculate function to find the total value of certain product ID’s. Find below how I can do this.

 

CALCULATE([Sales]

         ,FILTER(

            ALL('Product'[Product ID])

              ,'Product'[Product ID]="100"

              ||'Product'[Product ID]="101"

              ||'Product'[Product ID]="102")

)

 

However this is not what I am after unfortunately. I need the total value of invoices where these Product ID's exist.

 

If anyone has any idea it would be much appreciated!

1 ACCEPTED SOLUTION
v-sihou-msft
Microsoft Employee
Microsoft Employee

@Evan4

 

In this scenario, you need to use a CALCULATETABLE() to filter the corresponding Invoice first. Then use it to filter source table for your calculation. Please refer to my sample below:

 

Measure = CALCULATE (
    SUM ( Table1[Value] ),
    FILTER (
        VALUES ( Table1[Invoice] ),
        CALCULATE (
            COUNTROWS (
                CALCULATETABLE (
                    VALUES ( Table1[Invoice] ),
                    Table1[ProductID] = 100
                        || Table1[ProductID] = 101
                        || Table1[ProductID] = 102
                )
            )
        )
    )
)

555.PNG

 

 

Regards,

View solution in original post

1 REPLY 1
v-sihou-msft
Microsoft Employee
Microsoft Employee

@Evan4

 

In this scenario, you need to use a CALCULATETABLE() to filter the corresponding Invoice first. Then use it to filter source table for your calculation. Please refer to my sample below:

 

Measure = CALCULATE (
    SUM ( Table1[Value] ),
    FILTER (
        VALUES ( Table1[Invoice] ),
        CALCULATE (
            COUNTROWS (
                CALCULATETABLE (
                    VALUES ( Table1[Invoice] ),
                    Table1[ProductID] = 100
                        || Table1[ProductID] = 101
                        || Table1[ProductID] = 102
                )
            )
        )
    )
)

555.PNG

 

 

Regards,

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.