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

Measure based on 2 date columns

Hi all, 

 

I am trying to create a measure that shows the number of Job requests based on 2 Date columns.

 I'd like to have as result for Oct/18  76 Job request. 

 I have created a relation between a CALENDAR tab and REC 1 (using the request date as a key point on REC 1) and the following measures: 

 

DATE DATE:

 

Data Date = LASTDATE ( ALL ( 'Rec 1'[Request Date]) )

 

 

ON THE JOB:

 

ON THE JOB = IF (
    [Data Date] >= MIN ( 'Calendar'[Date] ),
    CALCULATE (
        DISTINCTCOUNT ( 'Rec 1'[Reference number] ),
        FILTER (
            'Rec1',
            COUNTROWS (
                FILTER (
                    RELATEDTABLE ( Rec 1),
                    'Rec 1'[Request Date] <= MAX ( Calendar[Date] )
                        && (
                            ISBLANK ( 'Rec 1'[Complete Date]) 
                                || 'Rec 1'[Complete Date] >= MAX ( Calendar[Date] )
                        )
                )
            )
                > 0
        )
    )
)

 

The problem is that this measure is retuning a number shorter than the right one. 

 

ON THE JOB calculation is based the month select on the slicer (Calendar tab), it should count all Job request that have : 

1. Request date same as the slicer

2. Complete date as same as the Slicer

3. Complete date blank.

 

In the sample attached, it should return 76 requests for Oct/18, the job reference number is highlited in blue for the right return results. 

 

Any help is much appreciate. 

 

SAMPLE DATA BASE (Excel)

 

Thanks ! 

3 ACCEPTED SOLUTIONS

Hi @Anonymous

 

You may refer to below measure. Delete the relationship between the two tables.

ON THE JOB =
CALCULATE (
    COUNT ( 'Rec 1'[Reference Number] ),
    FILTER (
        'Rec 1',
        'Rec 1'[Request Date] <= ENDOFMONTH ( Calendar[Date] )
            && (
                MONTH ( 'Rec 1'[Complete date] ) >= MONTH ( SELECTEDVALUE ( 'Calendar'[Date] ) )
                    || 'Rec 1'[Complete date] = BLANK ()
            )
    )
)

1.png

 

Regards,

Cherie

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Anonymous
Not applicable

Thanks you ! 

 

It works properly. 

View solution in original post

Hi,

 

You may download my PBI file from here.  I have maintained the relationship with the Date Table.

 

Hope this helps.

 

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

5 REPLIES 5
Ashish_Mathur
Super User
Super User

Hi,

 

Why should the answer be 76?  It should be 70.

 

  1. When the Completed data is filtered on Blanks, the number of rows are 61
  2. Clear the previous filter, filter the Request date on Oct and remove blanks from the Complete date column.  Number of rows left will be 2
  3. Clear the previous filter, filter the Completed date column on Oct.  Number of rows left will be 7

Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

Hi Ashish, 

 

Because to calculate for Oct/18, you should filter all requests that have Request Date that until Oct/18 (included) and Complete date as Oct, blank or beyond. 

 

In the Sample: 

 

1. Total of Job Request are 90. 

2. Request date on Oct or before are 88; 

3. Request date on Oct or before and Complete date as Oct, blank or beyond is 76. 

 

For example for September/18: 

1. Total of Job Request are 90. 

2. Request date on Sep or before are 71; 

3. Request date on Sep or before and Complete date as Sep, blank or beyond is 68. 

Hi,

 

You may download my PBI file from here.  I have maintained the relationship with the Date Table.

 

Hope this helps.

 

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi @Anonymous

 

You may refer to below measure. Delete the relationship between the two tables.

ON THE JOB =
CALCULATE (
    COUNT ( 'Rec 1'[Reference Number] ),
    FILTER (
        'Rec 1',
        'Rec 1'[Request Date] <= ENDOFMONTH ( Calendar[Date] )
            && (
                MONTH ( 'Rec 1'[Complete date] ) >= MONTH ( SELECTEDVALUE ( 'Calendar'[Date] ) )
                    || 'Rec 1'[Complete date] = BLANK ()
            )
    )
)

1.png

 

Regards,

Cherie

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Thanks you ! 

 

It works properly. 

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.