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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Evita_2023
Regular Visitor

Filters only selected month not dates after selected month as per measure

Hello,

I am having a issue, maybe you can help. 
I have vacancy data set, that consists of vacancy reference number (post_number), when vacancy was advertised and when vacancy was completed. 
I want to count number of roles for vacancies that were open during selected period. 
For example, if I am looking on month July, I should see all vacancies that were open during that month following conditions:
Completed date is greater then or equals to July or blank (as still open);
Vacancy authorised date is before or equals to July. 
I am using Date table to filter by month July and I can see only records with completed date July, but there should be as well records where vacancy was authorised in May, Completed in August, so it was open during July. 
I have two tables and both are joined with active relationship between Date table, Date column & Vacancies table, Completed date.
Relationships.JPG

 

This is the dax code for measure that I am using. You will notice that there are 2 conditions, to switch roles from 99 to 1 and to not include those vacancies with 16.06.2023 - that's all fine and it should be like that. 

Open Roles =
CALCULATE(
    SUMX('Vacancies', IF('Vacancies'[number_of_positions] = 99, 1, 'Vacancies'[number_of_positions])),
   
    FILTER(
        'Vacancies',
        (
            'Vacancies'[Completed_date] >= MIN('Date'[Date]) && -- Filters out vacancies with a 'Completed_date' greater than or equal to the minimum date in the 'Date' table
            'Vacancies'[Completed_date] <> DATE(2023, 6, 16) && -- Filters out vacancies with a 'Completed_date' equal to June 16, 2023
            'Vacancies'[Completed_date] >= MIN('Date'[Date]) - 60 // Modify this line to include July or later
        ) ||
        ISBLANK('Vacancies'[Completed_date]) // Includes vacancies with a blank 'Completed_date'
    ),
   
    'Vacancies'[Vacancy_authorised_date] <= MAX('Date'[Date]), // Filters out vacancies with a 'Vacancy_authorised_date' greater than the maximum date in the 'Date' table
    'Vacancies'[Vacancy_authorised_date] <> BLANK() // Filters out vacancies with a blank 'Vacancy_authorised_date'
)

 

This is the result that I get:

Result.JPG

 

This is the result that I am expecting to have:
expected result.JPG

 

 Clearly it takes into account only those vacancies where Completed date is July only even though I have conditions set in measure.

Can you please advise?
I have the same issue with other dashboards, like absence etc. 

Below is data set that I have. 

Post_numberJob_descriptionVacancy_authorised_dateCompleted_dateAdvertisedAdvertised_untilClosing_dateNumber_of_positions
255Vacancy 25531-Mar-2316-Jun-2316-Mar-2302-May-2302-May-231
178Vacancy 178 16-Jun-2306-Dec-2108-Dec-2108-Dec-211
298Vacancy 29830-Jan-2323-Jun-2320-Apr-2319-Jun-2319-Jun-231
33Vacancy 3316-Jun-2325-Jun-23   1
20Vacancy 2026-May-2327-Jun-2331-May-2323-Jun-2323-Jun-231
320Vacancy 32027-Apr-2328-Jun-2309-May-2305-Jun-2305-Jun-231
288Vacancy 28830-Mar-2305-Jul-23   1
250Vacancy 25018-Jan-2306-Jul-2319-May-2319-Jun-2319-Jun-231
264Vacancy 26416-Feb-2306-Jul-2301-Mar-2316-Mar-2316-Mar-231
23Vacancy 2331-May-2306-Jul-2309-Jun-2310-Jul-2310-Jul-231
284Vacancy 284 13-Jul-2319-Jun-2317-Jul-2317-Jul-231
43Vacancy 4305-Jul-2314-Jul-2306-Jul-2314-Jul-2314-Jul-231
301Vacancy 301 17-Jul-2320-Apr-2331-Jul-2331-Jul-2399
31Vacancy 3115-Jun-2326-Jul-2319-Jun-2331-Jul-2331-Jul-2399
304Vacancy 30413-Apr-2327-Jul-2320-Apr-2322-May-2322-May-231
277Vacancy 27717-Mar-2307-Aug-2323-Mar-2324-Apr-2324-Apr-231
40Vacancy 4028-Jun-2308-Aug-2329-Jun-2317-Jul-2317-Jul-231
65Vacancy 6531-Jul-2322-Aug-2304-Aug-2328-Aug-2328-Aug-231
12Vacancy 1223-May-2329-Aug-2302-Jun-2323-Jun-2323-Jun-231
76Vacancy 7607-Aug-2331-Aug-2308-Aug-2328-Aug-2328-Aug-231
326Vacancy 326     1
327Vacancy 327     1
328Vacancy 328     1
329Vacancy 329     1


Thank you

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

If you have blank Completed_Date values then you should not use an active connection between these two tables. Or you can see if "Show items with no data" is of any help.

View solution in original post

2 REPLIES 2
lbendlin
Super User
Super User

If you have blank Completed_Date values then you should not use an active connection between these two tables. Or you can see if "Show items with no data" is of any help.

Thank you. Blanks are important in this scenario, that means vacancy is still open. Even though I inserted dates and there was no blanks, still it didn't work. But you were right about inactive relationship. Due to complex filtering and measure, it gave me correct results only with inactive relationship.

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.