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
lennox25
Post Patron
Post Patron

Find the difference between two dates incorporating a deadline date

Hi, 

Please see table.

 

If Date Delivered is 14/11/2023 for Apples the deadline is <=2 days to Date Sold. How do I add a column adding on each deadline day to each category. The list is long and added to everyday. If I can get  columns with the Date Delivered plus the deadline date then I should be able to work out the difference between Datedelivered/Deadline date and Date Sold.  In this case it 2 days over the deadline.

 

lennox25_0-1707411108701.png

lennox25_1-1707411203585.png

 

1 ACCEPTED SOLUTION

Hi @lennox25 
Add a measure :

in_deadline % = 1-[%_over]
Ritaf1983_0-1707740174490.png

The updated pbix is attached

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

View solution in original post

10 REPLIES 10
Ritaf1983
Super User
Super User

Hi @lennox25 

You can import those tables to power query and merge between them:

Ritaf1983_0-1707451564371.pngRitaf1983_1-1707451601737.png

extract from the string of deadlines only the number of dates :

Ritaf1983_2-1707451815436.pngRitaf1983_3-1707451863755.png

modify data type to number

Ritaf1983_4-1707452148780.png

And add it to the sales date with a custom column

Ritaf1983_5-1707452225066.png

modify a result as a date data type

Ritaf1983_6-1707452271359.png

uncheck the option load to the model at the deadlines table ( you don't need it inside)

Ritaf1983_7-1707452390098.png

 

Pbix is attached

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.



Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

Hi @Ritaf1983 Thank you this seems to work for the over deadline. 

I've now been asked to work out within deadline days - can you help withi this please?

 

Thanks

Hi @lennox25 
Add a measure :

in_deadline % = 1-[%_over]
Ritaf1983_0-1707740174490.png

The updated pbix is attached

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

Perfect - Thank you for ALL your help on this one 🙂

Anonymous
Not applicable

Hi @lennox25 ,

 

You can try calculated column like below:

Deadline Date =
SWITCH (
    TRUE (),
    'YourTable'[Category] = "Apples", 'YourTable'[Date Delivered] + 2,
    'YourTable'[Category] = "Pears", 'YourTable'[Date Delivered] + 2,
    'YourTable'[Category] = "Oranges", 'YourTable'[Date Delivered] + 2,
    'YourTable'[Category] = "Bananas", 'YourTable'[Date Delivered] + 1,
    'YourTable'[Category] = "Grapes", 'YourTable'[Date Delivered] + 8,
    'YourTable'[Date Delivered]
)
Days Over Deadline =
DATEDIFF ( YourTable[Date Sold], YourTable[Deadline Date], DAY )

vkongfanfmsft_0-1707451216217.png

 

Best Regards,
Adamk Kong

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thats great and seems to work perfect - how would I now go about putting the Days Over deadline into a %?

percent from which variable? 

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

Hi @Ritaf1983 , I am trying to acheive the below which is in the smaller of the boxes.

lennox25_0-1707489911100.pnglennox25_1-1707489943856.png

 

Hi @lennox25 
You can create 3 measures : "
1.

total_transactions = COUNTROWS(sales)

Ritaf1983_0-1707491092485.png

over_deadline = CALCULATE([total_transactions],FILTER(sales,[over deadline days]<0))
Ritaf1983_1-1707491385286.png

%_over = divide ([over_deadline],[total_transactions])
+ Format it as percent
Ritaf1983_2-1707491476630.pngRitaf1983_3-1707491505658.png

The updated pbix is attached

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

Thank you - I will take a look at the PBI report you attached and hope it works 🙂 Will let you know

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.