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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
Bcomm_student
Regular Visitor

Calculating Days late with specific target times

Part of an assignment for university is making a table for some data showing delivery days and days late, and we only need to show values for the ones that were actually late. I have this table: 

Bcomm_student_0-1773337449668.png

And i've already made a column for actual delivery days. I can't remember what the basic formula was for tasks like these so all help is appreciated.

1 ACCEPTED SOLUTION

Hi,

Write this calculated column formula in the Regions table

Target = 1*(LEFT(Regions[Target Days],SEARCH(" ",Regions[Target Days])-1))

Write these calculated columns in the Data table

Diff = 1*('Data'[Delivery Date]-'Data'[Order Date])
Target = CALCULATE(MAX(Regions[Target]),FILTER('Regions','Data'[Customer Province]='Regions'[Location]))
Column 2 = if(Data[Diff]<Data[Target],"early",if(Data[Diff]=Data[Target],"on time","late"))

Hope this helps.

Ashish_Mathur_0-1773459586625.png

 


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

View solution in original post

10 REPLIES 10
v-saisrao-msft
Community Support
Community Support

Hi @Bcomm_student,

Have you had a chance to review the solution we shared by @Kedar_Pande ? If the issue persists, feel free to reply so we can help further.

 

Thank you.

Kedar_Pande
Super User
Super User

@Bcomm_student 

 

Hey no worries, this one's dead simple. Create a measure called Days Late:

Days Late = 
IF(
[Actual Delivery Days] >
LOOKUPVALUE(
Targets[Target Days],
Targets[Region], SELECTEDVALUE(Regions[Region])
),
[Actual Delivery Days] -
LOOKUPVALUE(
Targets[Target Days],
Targets[Region], SELECTEDVALUE(Regions[Region])
)
)

Put it in your table/matrix. It'll show blank for on-time deliveries, and positive numbers for late ones. Just make sure your Region column connects the fact table to that Targets lookup table properly.

 

If this answer helped, please click 👍 or Accept as Solution.
-Kedar
LinkedIn: https://www.linkedin.com/in/kedar-pande

cengizhanarslan
Super User
Super User

You can calculate Days Late by comparing the actual delivery days with the target delivery days for the region. First, make sure you have a column (or relationship) that gives the Target delivery days for each region. Then create a calculated column like this:

Days Late =
VAR LateDays =
    Data[Actual Delivery Days] - Data[Target delivery days]
RETURN
IF ( LateDays > 0, LateDays, BLANK() )

 

_________________________________________________________
If this helped, ✓ Mark as Solution | Kudos appreciated
Connect on LinkedIn | Follow on Medium
AI-assisted tools are used solely for wording support. All conclusions are independently reviewed.

Will this work with groups? Grouping them into specific regions was easier and I have my delivery duration column, but I think the issue now was I made groups rather than an actual column.

Bcomm_student_0-1773345404354.png

Bcomm_student_1-1773345465081.png

 

 

@Bcomm_student 

pls provide some sample data and expected output.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Here's some of my provided/current data: 

Bcomm_student_0-1773381534540.png

Bcomm_student_1-1773381547134.png

And these were the assignment instructions; my question mainly concerned part c and d 

Bcomm_student_2-1773381664403.png

 

 

@Bcomm_student 

1. do the data transform in PQ

11.png

then create a column

 

Column =
var _day='Table'[Delivery Date]-'Table'[Order Date]
var _target=maxx(FILTER('Table (2)','Table'[Customer Province]='Table (2)'[Locations]),'Table (2)'[day])
return if(_day<_target,"early",if(_day=_target,"on time","late"))
12.png
pls see the attachment below




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




I'm not sure how to send files in replies but I get an error with that formula. Maybe I need to get rid of the Region group from before transforming the data?

https://limewire.com/d/1FQDe#tVCsg7FMKW 

@Bcomm_student 

i can't edit in your file directly, since it linked to the file on your own pc. pls see the attachment below





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Hi,

Write this calculated column formula in the Regions table

Target = 1*(LEFT(Regions[Target Days],SEARCH(" ",Regions[Target Days])-1))

Write these calculated columns in the Data table

Diff = 1*('Data'[Delivery Date]-'Data'[Order Date])
Target = CALCULATE(MAX(Regions[Target]),FILTER('Regions','Data'[Customer Province]='Regions'[Location]))
Column 2 = if(Data[Diff]<Data[Target],"early",if(Data[Diff]=Data[Target],"on time","late"))

Hope this helps.

Ashish_Mathur_0-1773459586625.png

 


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

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.