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
Karolina411
Resolver II
Resolver II

DAX to find end dates and count them that are in between Date Dimension

I am transferring reports from EXCEL To Power BI and this existing

DAX is not working well in my Power BI and is producing much higher numbers than excel.  The goal is locate and count patients whose Case Management ENDDATE is between each month to determine the # of closed cases. Very frustating.

ClosedCases:=CALCULATE(COUNTROWS('LOS CM'),FILTER('LOS CM',[EndDate]>=STARTOFMONTH(DateDim[DateValue])&& [EndDate]<=ENDOFMONTH(DateDim[DateValue])))

1 ACCEPTED SOLUTION
v-xiaotang
Community Support
Community Support

Hi @Karolina411 

If you want to get count per month, try the measure below, it returns the count of patients whose Case Management ENDDATE is between each month

 

ClosedCases :=
CALCULATE (
    COUNTROWS ( 'LOS CM' ),
    FILTER (
        ALL ( 'LOS CM' ),
        MONTH ( 'LOS CM'[EndDate] ) = MONTH ( MIN ( 'LOS CM'[EndDate] ) )
    )
)

vxiaotang_0-1647416324311.png

 

 

Best Regards,

Community Support Team _Tang

If this post helps, please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-xiaotang
Community Support
Community Support

Hi @Karolina411 

If you want to get count per month, try the measure below, it returns the count of patients whose Case Management ENDDATE is between each month

 

ClosedCases :=
CALCULATE (
    COUNTROWS ( 'LOS CM' ),
    FILTER (
        ALL ( 'LOS CM' ),
        MONTH ( 'LOS CM'[EndDate] ) = MONTH ( MIN ( 'LOS CM'[EndDate] ) )
    )
)

vxiaotang_0-1647416324311.png

 

 

Best Regards,

Community Support Team _Tang

If this post helps, please consider Accept it as the solution to help the other members find it more quickly.

tamerj1
Super User
Super User

Hi @Karolina411 

you have to get red of excel's mentality while working while working with DAX

First set the relationship between the date column of the date table with the EndDate column of your patients table.

2nd build you measure which should be COUNTROWS ( DISTINCT ( 'LOS CM'[Patient ID] ) ) 

If you don't have a patient id column and you 100% sure there are no duplicate records of the same patient then you can use just COUNTROWS  ( 'LOS CM' )

The in the matix visualplace the Year and underneath it the month on the raws. Then place the your measure in the Values

 

On case you already have a relationship between the two tables, then you can build an in active relationship as described above and then activate it using CALCULATE ( [Mesure], USERELATIONSHIP ( the date column from date table, the end date colum from the patient's table ))

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.