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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Calculate the number of skipped intervals, planned vs completed

Hi, I am trying to create a measure that would count the number of intervals that were skipped on a project.  A project can have x amount of sub projects.  Each sub project has x amounts of planned intervals.  Once there is completed data, it is submitted to another table.  If an interval is not completed, no data is submitted.  Here is an example of the data:

 

Planned data

ProjectIDIDSubProjectIDIntervalNumberProgToBeTreated
111229617Y
111229616Y
111229615Y
111229614Y
111229613Y
111229612Y
111229611Y
111229605Y
111229604Y
111229603Y
111229602Y
111229601Y
111229594Y
111229593Y
111229592Y
111229591Y

 

active/completed data

ProjectIDIDSubProjectIDIntervalNumber
111229614
111229612
111229611
111229603
111229602
111229601
111229594
111229592
111229591

2961 and 2959 have skipped interval 3 and moved directly onto 4.  I am trying to create a measure that would record those 2 skipped intervals without data.  The following formula works when the job is completed, but I would like to have an active count.

SkippedIntervals = calculate(COUNT(PlannedTable[Intervalnumber]),PlannedTable[ProgToBeTreated]="Y")-CALCULATE(COUNT(CompletedTable[IntervalNumber]))
 
I tried to add a max interval variable, but it is not dynamic when 2961 has a max of 4, but 2960 has a max of 3
 
SkippedIntervals =
var MAXInterval = calculate(MAX(CompletedTable[IntervalNumber]))
return
calculate(COUNT(PlannedTable[Intervalnumber]),PlannedTable[ProgToBeTreated]="Y",PlannedTable[IntervalNumber]<=MAXInterval)-CALCULATE(COUNT(CompletedTable[IntervalNumber]))

 

Any help is appreciated

 

 

4 REPLIES 4
mahoneypat
Microsoft Employee
Microsoft Employee

Here is one measure expression that should work.

 

SkippedIntervals =
VAR vSummary =
    ADDCOLUMNS (
        SUMMARIZE ( Projects, Projects[ProjectIDID], Projects[SubProjectID] ),
        "@Max"CALCULATE ( MAX ( Projects[IntervalNumber] ) ),
        "@Intervals"CALCULATE ( COUNTROWS ( Projects ) )
    )
RETURN
    SUMX ( vSummary, [@Max] - [@Intervals] )

 

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Anonymous
Not applicable

With some additional testing, the solution I put forward is incorrect.  Looking for additional help :C

Anonymous
Not applicable

Would this be an acceptable solution?  I don't have the dataset to 100% test this yet to see if it would be dynamic for each SubProjectID.  Just building off your solution here:

SkippedIntervalsNew =
VAR vSummary =
ADDCOLUMNS (
SUMMARIZE ( Completed, Completed[STEPProgrammedPadID], Completed[STEPProgrammedWellID] ),
"@Max", CALCULATE(MAX ( Completed[IntervalNumber] )) ,
"@Intervals", CALCULATE ( COUNTROWS ( Completed) ),
"@PlannedSkips", CALCULATE( COUNTROWS (Planned), Planned[ProgToBeTreated]="N",FILTER(Planned,Planned[IntervalNumber]<MAX ( Completed[IntervalNumber] )))
)
RETURN
SUMX ( vSummary, [@Max] - [@Intervals] -[@PlannedSkips])
Anonymous
Not applicable

Thanks so much for quick response!  This solves about 90% solutions.  I have one quick question that I hope is an easy answer.  In the PlannedData, there is a ProgToBeTreated column.  Sometimes it is planned to skip treating an interval.  How would I go about subtracting the intervals that were planned to be skipped, once @ max has reached/past those intervals?  Thanks!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.