DAX formula behaving like countifs.

countryfan_nt

Well-known Member
Joined
May 19, 2004
Messages
758
Hello friends, Hope all is well!

please help me fix the following DAX formula. I want to distinct count the Invoice Numbers, provided that the
the invoice dates, name of branches, and patient ID match.

the formula below is not working; I am getting the following error:
Capture.JPG

Thank you very much in advance!

VBA Code:
=CALCULATE (

    DISTINCTCOUNT( 'TRT RAW DATA'[Invoice Number] ),

    'TRT RAW DATA'[Invoice Date] = VALUES ( 'TRT RAW DATA'[Invoice Date] ) &&

    'TRT RAW DATA'[Name of Branch] = VALUES ( 'TRT RAW DATA'[Name of Branch] ) &&

    'TRT RAW DATA'[PatientID] = VALUES ( 'TRT RAW DATA'[PatientID] )

)
 
If you put it in a calculated column, you will get the same distinct count for every row that matches those three items. That doesn't make sense to me for a calculation you are going to use in a pivot table as it will be duplicated.
So, how do you plan to use it in a pivot table? If you are going to have the Invoice Date, patient ID and Branch in the pivot, then all you actually need is a distinct count of the invoice number. If not, then you probably need to summarize by the 4 columns, or create a key column that concatenates those 4 columns, then use a countrows statement in a measure.
 
Upvote 0

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.

Forum statistics

Threads
1,215,873
Messages
6,127,464
Members
449,384
Latest member
purevega

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top