I have an invoice table with columns including InvoiceNo and ProductID. I need to be able to filter so that it returns all Invoices that contain a particular Product. When this filter is applied, it needs to only display the invoices with that product, but it should show all products on that invoice.
For example, I have the following table:
InvoiceNo ProductID 111 ProdA 111 ProdB 111 ProdC 222 ProdA 222 ProdB
I only want to display invoices that have ProdC. When filtered, it needs to show
InvoiceNo ProductID 111 ProdA 111 ProdB 111 ProdC
I have tried the following DAX Measure:
CALCULATE( COUNTROWS(Invoice), SUMMARIZE( FILTER( SUMMARIZE( Invoice ,Invoice[InvoiceNo] ,Invoice[ProductID] ) ,Invoice[ProductID] = "ProductC" ) ,Invoice[InvoiceNo] ) )
But when I apply the filter (where measure > 0), it only returns the following
InvoiceNo ProductID 111 ProdC
If I was doing this in SQL, I would use the following query:
select [InvoiceNo] ,[ProductID] from [Invoice] where [InvoiceNo] in (SELECT [InvoiceNo] FROM [Invoice] where [ProductID] = 'ProdC')