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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Employee
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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors