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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
cferv_77
Helper I
Helper I

Count the number of rows that satisfies date filter condition

Hello,

 

I am trying to create a measure that counts the number of cases open given a date.

 

I tried typing up this measure. I have date table and is has an active relationship with order date and inactive with date delivered. The idea is the find out the count of non-closed cases any point in time. 

The measure below doesn’t work the way the way I want it because it doesn’t seem to capture ALL the cases that fall under the filter condition.

 

Headcount =

var selected = SELECTEDVALUE('Date'[Date])

return

CALCULATE(COUNTA('Cases'[ID]), USERELATIONSHIP('Date'[Date],'Cases'[Date Delivered]), AND('Cases'[Order Date] <= selected, OR(ISBLANK('Cases'[Date Delivered]), selected  <'Cases'[Date Delivered]))) + 0

 

 

IDOrder DateItemDate Delivered
16/3/201923/26/2020
212/7/202033/24/2022
33/19/201843/25/2020
48/24/202093/20/2021
51/25/20216 
69/8/202013/19/2021
78/2/201933/5/2020
1 ACCEPTED SOLUTION
johnt75
Super User
Super User

Open case =
var maxDate = MAX( 'Date'[Date])
return CALCULATE( COUNTROWS(Cases), REMOVEFILTERS('Date'),
Cases[Order date] <= maxDate &&
(Cases[Delivered date] > maxDate || ISBLANK(Cases[Delivered date])
)

View solution in original post

2 REPLIES 2
johnt75
Super User
Super User

Open case =
var maxDate = MAX( 'Date'[Date])
return CALCULATE( COUNTROWS(Cases), REMOVEFILTERS('Date'),
Cases[Order date] <= maxDate &&
(Cases[Delivered date] > maxDate || ISBLANK(Cases[Delivered date])
)

Hello @johnt75 

 

Thanks for the solution, but then number looks off when I used it. And I think it check/test it with a table visual because I guess of the RemoveFilters() function. Is there an alternate solution?

 

EDIT: Apologies, I double checked. It gave me the correct number. I'll accept your solution.

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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