DAX formula behaving like countifs.

countryfan_nt

Well-known Member
Joined
May 19, 2004
Messages
765
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] )

)
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Maybe?

Excel Formula:
=countrows(summarize('TRT RAW DATA',[Invoice Date],[Name of Branch],[PatientID]))
 
Upvote 0
You can create a table like this and measure based on this new table

Table:
Excel Formula:
newTable =summarize('TRT RAW DATA', [Invoice Number], [Invoice Date],[Name of Branch],[PatientID])

Measure:
Excel Formula:
 UniqueNum =distinctcount(newTable[Invoice Number])
 
Upvote 0
Match what? Where are you using the measure?
Hi and thank you for your reply, please take a look at the attached image.
please help me with a DAX formula that will act like countifs.

by match I mean if: Invoice Number, InvoiceDate, PatientID are the same distinct count the invoice numbers.

Thank you very much in advance
 

Attachments

  • 1708522625946.png
    1708522625946.png
    11.2 KB · Views: 7
Upvote 0
That doesn't answer my question - where are you using this? As a measure in a pivot table, or a calculated column?
 
Upvote 0
Why do you want it in a calculated column? How do you intend to use it?
 
Upvote 0
Why do you want it in a calculated column? How do you intend to use it?
I am not an expert, it will be placed in calculated field then to a power pivot. Do please suggest a better way to do it.
btw I came up with a formula, but will be happy to apply an easier option:

VBA Code:
=CALCULATE (

COUNTROWS ( T ),

FILTER (

T,

T[InvoiceDate] = EARLIER([InvoiceDate] )&&

T[PatientID] = EARLIER([PatientID] ) &&

T[Name of Branch] = EARLIER([Name of Branch])))
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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