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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
mmcquil2
Frequent Visitor

Count data point for each month it is overdue

I have a dataset pulled from SAP Maintenance with Basic Finish dates and Required End dates. If the basic finish is after the required end date then that work order is considered overdue. It is also overdue if the work order is still open past the required end date. 

 

I am looking at all work order data from January 2018 to now and would like to create a trend to show month by month, how many Work Orders were over due. The issue is some work orders are completed way past the required end so they would need to be counted for multiple months. There are also work orders that are completed on time that never should be counted as overdue. 

 

I figure there is a measure that I could create but not sure what the logic looks like. I had created the following for a different dataset: 

CALCULATE(COUNTROWS('All IWR''s'),FILTER('All IWR''s','All IWR''s'[Open Date]<=MAX(Calendar[Date])&& 'All IWR''s'[Close Date]>=MIN(Calendar[Date])))
however this requires that the open date is always before the close date. That is not necessarily the case with my new dataset.
 
I have tried looking around for solutions but have found none. Any help would be appreciated.
 
Thanks,
Michael
 
9 REPLIES 9
johnt75
Super User
Super User

You could try something like

# Overdue orders =
VAR maxDate =
    MAX ( 'Date'[Date] )
VAR minDate =
    MIN ( 'Date'[Date] )
RETURN
    CALCULATE (
        COUNTROWS ( 'Table' ),
        'Table'[Required End] >= minDate
            && 'Table'[Required End] <= maxDate
            && (
                'Table'[Basic Finish] > 'Table'[Required End]
                    || ISBLANK ( 'Table'[Basic Finish] )
            )
    )

Make sure that your Date table isn't connected to the work orders table. If it has to be connected you may need to add a REMOVEFILTERS('Date') into the CALCULATE statement

mmcquil2
Frequent Visitor

So that did not seem to work. I have the calendar table as a seperate file. I am just getting 1 single result for every month (an image is posted below). I have about 6000 rows of data but have also pasted an example. 

 

Any edits to the formula that would remedy this?

 

mmcquil2_0-1655304362252.png

mmcquil2_1-1655304423494.png

 

 

Try

# Overdue orders =
VAR maxDate =
    MAX ( 'Date'[Date] )
VAR minDate =
    MIN ( 'Date'[Date] )
RETURN
    CALCULATE (
        COUNTROWS ( 'Table' ),
        REMOVEFILTERS ( 'Date' ),
        'Table'[Required End] >= minDate
            && 'Table'[Required End] <= maxDate
            && (
                'Table'[Basic Finish] > 'Table'[Required End]
                    || ISBLANK ( 'Table'[Basic Finish] )
            )
    )
mmcquil2
Frequent Visitor

I got the same result.

 

mmcquil2_0-1655305185582.png

 

Are any other filters being applied which could affect it?

You can use Performance Analyzer to grab the DAX code for the visual and have a look at it in DAX Studio. That will show exactly which filters are being applied.

mmcquil2
Frequent Visitor

I have no filters applied to the visual or the page.

 

mmcquil2_0-1655306358731.png

 

What is Complex ? Is that in 'Sheet 2' or another table? If another table, how is that related to 'Sheet 2'?

mmcquil2
Frequent Visitor

It is in sheet 2 as seen in the above snapshot.

 

Thanks,

Michael

Anonymous
Not applicable

@mmcquil2 I am trying to achieve the same result.  The error i get is when comparing Required End date in the last part of the filter.  It seems to want an aggregate here.

 

Below you can see my complete code,

Actions Open and Overdue = 
   var MaxDate = MAX(Date_Calendar_Lookup[DateID])
    var MinDate = MIN(Date_Calendar_Lookup[DateID])
    
    RETURN 
        CALCULATE( 
            COUNTROWS(reducedactions),
            REMOVEFILTERS(Date_Calendar_Lookup),
            reducedactions[due_date]>=MinDate 
            && reducedactions[due_date]<=MaxDate 
            && ( 
                reducedactions[completed_at]>reducedactions[due_date]
                  || ISBLANK(reducedactions[completed_at] ) 
                ) 
            )

 

the part that DAX does not like syntactically is

JohnAnderson__0-1657509032853.png

 

Any assistance with this would be appreciated.  

 

Thanks,

John.

Helpful resources

Announcements
November Fabric Update Carousel

Fabric Monthly Update - November 2025

Check out the November 2025 Fabric update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Users online (27)