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
Svendu
Frequent Visitor

Dynamic count based on open and start date with date filter slicer

Dear community, 

I am looking for a solution to count or show a specific status depending on a start and end date. 

Use case: data from a recruiting tool. Jobs are "open" as soon as there is a start date and "Filled" as soon as there is a "Date Closed". 

I would like to achieve to find the count of jobs that were "open" at a certain date or date range when filtering by date dynamically and finally having also charts to show the evolution over time. 

 

I have placed this issue several times and seen several similar posts but I could neither replicate the already existing solutions nor the ones that had been kindly provided to me. I am not sure if there is an issue in my date table (counting in fiscal years starting in July), the relationships or the formulas themselves. 

 

Thank you very much in advance!!

 

Summary:

 

Svendu_0-1670487170831.pngSvendu_1-1670487179817.png

Solution 1 proposed =
VAR _N1 =CALCULATE (COUNT ( Jobs[Job Req ID] ),
FILTER (ALL ( Jobs),
Jobs[Date Created]>= SELECTEDVALUE ( 'Fiscal Year Table'[Date] )
&& [Closed Date] = BLANK ()
&& [Status] = "Open"
)
)
VAR _N2 =CALCULATE (COUNT ( Jobs[Job Req ID] ),
FILTER (ALL ( Jobs ),
[Date Created] <= SELECTEDVALUE ( 'Fiscal Year Table'[Date] )
&& [Closed Date] >= SELECTEDVALUE ( 'Fiscal Year Table'[Date] )
&& [Status] = "Filled"
)
)
RETURN
_N1 + _N2
 
Svendu_2-1670487244102.png

 

Solution 2 proposed =
VAR _MAXDATE =
MAX ( 'Fiscal Year Table'[Date] )
RETURN
IF (
MAX ( Jobs[Date Created] ) <= _MAXDATE,
IF (
MAX ( Jobs[Closed Date] ) = BLANK ()
|| MAX ( Jobs[Closed Date] ) >= _MAXDATE,
"Open",
"Filled"
),
"Filled"
)
 
Svendu_3-1670487282733.png

 

Date Table:

Fiscal Year Table = CALENDARAUTO(6)
Fiscal Month N° = (MONTH(EDATE('Fiscal Year Table'[Date], -6)))
Fiscal Quarter = "Q" & (QUARTER(EDATE('Fiscal Year Table'[Date], -6)))
Fiscal Year =
VAR CurrYear = RIGHT(YEAR('Fiscal Year Table'[Date]),2)
VAR LastYear = RIGHT(YEAR('Fiscal Year Table'[Date])-1,2)
VAR NewYear = RIGHT(YEAR('Fiscal Year Table'[Date])+1,2)
VAR FiscalYear =
SWITCH(
TRUE(),
MONTH('Fiscal Year Table'[Date]) >= 4,
CurrYear & "-" & NewYear,
LastYear & "-" & CurrYear
)
RETURN
FiscalYear

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

5 REPLIES 5
v-jingzhang
Community Support
Community Support

Hi @Svendu 

 

Things will be different when you filter on a specific Date or a date range. When filtering only a specific date, the current solution 1 and solution 2 should work well as one date could only be a created date, or a closed date, or a date between those two dates. The status is easy to judge. 

 

However, when you filter to a date range, let's take a month as an example, there are four situations for the status of a job Req. I draw a picture as below. If we select Jan 2020, the status of situation 4 is clear to be "Open" based on your description. 

vjingzhang_0-1670552423255.png

 

For situation 1, it was created and closed in the same month and the range between two dates are less than the month range, so do you want to count it as "Open" or "Filled" in Jan 2020?

 

For situation 2 and 3, their Req open ranges cross two months and neither calendar month is fully covered. So how do you want to count their status in two months? 

 

These situations also happen when you expand the filtered range to a quarter or a year. Apparently the situation 2 in my example cross two different quarters and different years. You need to determine how you want to count the status for job Reqs that have the situation 1, 2, 3. Give us a specific result "Open" or "Filled" for each month. Then we can help provide a solution that can meet your need. We cannot make the decisions for you on whether it should be "Open" or "Filled". 

 

Best Regards,
Community Support Team _ Jing

Hi Jing,

 

Thank you very much for your answer. 

The scenarios you drew are exactly the behaviour I am trying to calculate. 

It doe not have to show "Open" or "Filled" I thought it could be an option to calculate it easier if it was shown. 

The rational would be to count the number of reqs that were open, but does not need to show "open". As per your example above it should count:

Svendu_0-1670579286862.png

 

Is this feasible? 

To answer the question regarding 2 and 3: As long as in a month it was open it should count as such even if it was filled inbetween. 

 

Let me know if it is clear enough.

Unfortunately I could not upload the pbix, it tells me "the file type pbix is not supported". If there is a way to upload it I can send you the sample.  

 

 

 

 

 

Svendu
Frequent Visitor

Hi @v-jingzhang ,

 

MAybe additionally, I saw the following post from last year that looked promising, but again, I could not make it work for my case:

https://community.powerbi.com/t5/Desktop/Filtering-records-based-on-a-record-date-within-another-rec...

 

Thank you very much for all your efforts.

Sven

Svendu
Frequent Visitor

Job Req IDStatusDate CreatedClosed Date
1Filled1.16.20183.8.2018
2Filled1.16.20184.17.2018
3Filled1.16.20186.20.2018
4Filled1.23.20183.6.2018
5Filled1.25.20183.19.2018
6Filled2.12.20186.25.2018
7Filled2.12.20186.13.2018
8Filled2.13.20187.5.2018
9Filled2.14.20185.8.2018
10Filled2.19.20186.25.2018
11Filled2.19.20186.27.2018
12Filled2.19.20185.29.2018
13Filled2.19.20184.2.2018
14Filled2.19.20184.17.2018
15Filled2.19.20184.13.2018
16Filled2.19.20186.7.2018
17Filled2.19.20188.1.2018
18Filled2.20.20184.2.2018
19Filled2.22.20187.16.2018
20Filled2.22.20184.13.2018
21Filled3.14.20187.20.2018
22Filled4.5.20185.16.2018
23Filled4.5.20187.2.2018
24Filled4.12.20186.25.2018
25Filled4.19.20186.6.2018
26Filled4.27.20185.11.2018
27Filled5.3.20186.11.2018
28Filled5.16.20187.5.2018
29Filled5.16.20186.6.2018
30Filled6.14.20187.23.2018
31Filled6.28.20187.10.2018
32Filled6.29.20188.21.2018
33Filled7.2.20189.11.2018
34Open7.12.2019 
35Filled7.15.201912.19.2019
36Open7.15.201912.2.2019
37Filled7.15.20199.24.2019
38Filled7.15.20199.24.2019
39Filled7.15.20192.4.2020
40Filled7.15.201910.2.2019
41Filled7.16.20193.2.2020
42Filled7.16.20198.6.2019
43Filled7.16.20198.20.2021
44Filled7.16.20199.24.2019
45Filled7.16.20198.15.2019
46Filled7.16.20199.24.2020
47Filled7.16.20193.9.2020
48Filled7.16.20194.29.2020
49Filled7.16.20192.28.2020
50Filled7.16.20197.18.2019
51Filled7.17.20198.23.2021
52Filled7.18.201911.12.2019
53Filled7.18.201910.7.2019
54Filled7.18.201912.9.2019
55Filled7.18.201912.3.2020
56Filled7.18.201910.31.2019
57Open7.18.201911.6.2019
58Open7.18.201912.16.2019
59Filled7.19.201910.1.2019
60Filled7.23.201910.1.2019
61Filled7.26.20198.19.2021
62Filled7.26.20194.30.2020
63Filled7.26.20194.1.2020
64Filled8.5.20193.9.2020
65Filled8.5.20197.14.2021
66Filled8.5.20192.22.2021
67Filled8.7.201910.31.2019
68Filled8.7.20194.28.2020
69Filled8.8.20199.24.2019
70Filled8.8.20192.24.2020
71Filled8.8.20192.24.2020
72Filled8.8.20193.4.2020
73Filled8.12.20194.28.2020
74Filled8.16.201910.31.2019
75Filled8.16.20191.30.2020
76Filled8.21.201910.31.2019
77Filled8.26.201911.26.2019
78Filled8.27.20199.16.2021
79Filled8.27.20199.16.2021
80Filled8.27.20199.16.2021
81Filled8.27.20199.16.2021
82Filled8.27.20199.16.2021
83Filled8.27.20199.16.2021
84Filled8.27.20199.16.2021
85Filled8.27.20199.16.2021
86Filled8.27.20199.16.2021
87Filled8.30.201911.20.2019
88Filled9.2.201911.4.2019
89Filled9.4.20192.18.2020
90Filled9.4.20198.6.2020
91Filled9.10.20192.17.2020
92Filled9.17.201910.17.2019
93Filled9.18.20193.10.2020
94Filled9.20.20194.8.2020
95Filled9.20.20193.17.2020
96Filled9.23.20193.10.2020
97Filled9.25.20191.30.2020
98Filled9.26.201911.20.2019
99Filled9.27.20193.10.2020
Svendu
Frequent Visitor

If anyone can tell me how to upload the pbix, I can send the file, but it tells me it is not supported...

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.