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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
Anonymous
Not applicable

Help with my first DAX formula relating two tables

I have two tables (see screenshot below)

1. Encounters - List all appt encounters including the date of the encounter and flags indicating if the encounter is a New Patient, Seen in 10 Business Days, etc.

2.  Dates -  list of dates including flags to show whether or not the date occurs this month. 

 

I would like to count encounters where New_Patient_Visit = 1 and where Date of Encounter is Equal to a Calendar_DT in the Dates table where Current Month Flag = 1

 

In SQL it would look like this

SELECT COUNT(E.NEW_PATIENT_VISIT)

FROM ENCOUNTERS E

INNER JOIN DATES D ON E.ENC_DATE = D.CALENDAR_DT

WHERE E.NEW_PATIENT_VISIT = 1 AND D.[Current Month Flag] = 1

 

Thanks in advance!

dax question.jpg

 

 

4 REPLIES 4
v-ljerr-msft
Microsoft Employee
Microsoft Employee

Hi @Anonymous,

 

In addition, using FILTER Function (DAX) should also meet your requirement.

Countingpatients :=
    CALCULATE (
        COUNTA ( Encounters[New_Patient_Visit] ),
        FILTER (
            Encounters,
            Encounters[New_Patient_Visit] = "1"
                && RELATED ( Dates[Current Month Flag] ) = "1"
        )
    )

 

Regards

Anonymous
Not applicable

Are there are any speed or efficiency considerations when deciding to use the FILTER function?

 

Thanks in advance

Passing filters direct to CALCULATE is more faster than using iterrator function like FILTER. However, Whenever, you would like to compare columns to columns or columns to measures etc., FILTER function must be used. For simple filters like your report, You can pass direct filters to CALCULATE. 

Thanks & Regards,
Bhavesh

Love the Self Service BI.
Please use the 'Mark as answer' link to mark a post that answers your question. If you find a reply helpful, please remember to give Kudos.
BhaveshPatel
Community Champion
Community Champion

This measure will count all the patients visit where new patient visit is 1 and current month flag is 1.

 

Countingpatients:= CALCULATE(COUNTA(Encounters[New_Patient_Visit]),[New_Patient_Visit]="1",[Current Month Flag]="1")

 

Hoping that this is what you would like to achieve. 

Thanks & Regards,
Bhavesh

Love the Self Service BI.
Please use the 'Mark as answer' link to mark a post that answers your question. If you find a reply helpful, please remember to give Kudos.

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.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors