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

Measure Problem in calculating a delay

Dear PowerBi community:

I would like to ask for your help in correcting a formula that does not work correctly.

What I would like to create is a measure that computes the a delay through a series of weeks.

I think it would be clearer if I show you an example:

 

I have two dates column (Planned and Actual) associeted to a document:

F_Cannata_0-1650532165886.png

Because Date Actual is higher than Planned the document is in delay.

So, in my visual I should obtain for  January 2 (end of the first week) 6 days of delay

for 9 january 13 days of delay, and so on.

Then, I would like to repete this procedure for a wider list of document.

F_Cannata_1-1650532480168.png

For instance, the 30th of January I will have the delay of Doc 3 and Doc 8 (12 days) + the delay of  Doc 7

This calculation should be done until the date of actual. Therefore, after February 24 I should not have any overdue document.

 

For this scope I created this measure:

F_Cannata_2-1650532710677.png

With this calendar table:

F_Cannata_3-1650532722153.png

and with these reletionships:

F_Cannata_4-1650532742782.png

What I obtain is this:

F_Cannata_5-1650532769069.png

The Doc Code 7 of 2rd of January is 6 Days late (which is correct).

However, when I look at the 9th of january the delay of this document is not recorded in the visual (there should be 13 days of delay as I said before). The next value which is shown in the visual refers to the others 2 documents planned for 24 of january (for which the actual date is later in February) and the delay is 12 days ( and therefore it still does't take into account the delay of doc Code 7 which was received the 9th of February).

Do you have any idea how I can correct my measure?

Sincerely,

Francesco.

1 ACCEPTED SOLUTION
v-jingzhang
Community Support
Community Support

Hi @Anonymous

 

Please try this measure if I understand it correctly. And keep two tables disconnected

Delay = 
VAR DelayPerWeek =
    SUMX (
        Sheet1,
        IF (
            MAX ( 'Calendar'[WeekEnding] ) > Sheet1[Planned]
                && (
                    MAX ( 'Calendar'[WeekEnding] ) < Sheet1[Actual]
                        || ISBLANK ( Sheet1[Actual] )
                ),
            DATEDIFF ( Sheet1[Planned], MAX ( 'Calendar'[WeekEnding] ), DAY ),
            0
        )
    )
VAR Limit_Calendar =
    MAX ( 'Calendar'[Date] )
RETURN
    IF ( TODAY () > Limit_Calendar, DelayPerWeek / 7, BLANK () )

 

If you put the variable DelayPerWeek into a single measure, you will see its result which is correct. 

vjingzhang_0-1650880324857.png

 

I have attached my sample file for your reference. 

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

View solution in original post

1 REPLY 1
v-jingzhang
Community Support
Community Support

Hi @Anonymous

 

Please try this measure if I understand it correctly. And keep two tables disconnected

Delay = 
VAR DelayPerWeek =
    SUMX (
        Sheet1,
        IF (
            MAX ( 'Calendar'[WeekEnding] ) > Sheet1[Planned]
                && (
                    MAX ( 'Calendar'[WeekEnding] ) < Sheet1[Actual]
                        || ISBLANK ( Sheet1[Actual] )
                ),
            DATEDIFF ( Sheet1[Planned], MAX ( 'Calendar'[WeekEnding] ), DAY ),
            0
        )
    )
VAR Limit_Calendar =
    MAX ( 'Calendar'[Date] )
RETURN
    IF ( TODAY () > Limit_Calendar, DelayPerWeek / 7, BLANK () )

 

If you put the variable DelayPerWeek into a single measure, you will see its result which is correct. 

vjingzhang_0-1650880324857.png

 

I have attached my sample file for your reference. 

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

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.