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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Stéphane
Frequent Visitor

Calculate a new date additioning date+Working days

Hi all,

I need your knowledge to solve following question:

I have 2 tables:

- Sales order, with Created date

- Calendar table, from 2015 to 2025, with an additionnal column Working days (0 or 1 value)

I am trying to calculate in a new column a Sales order Treatment limit date, so that Treatment limit date = Created date + 3 working days.

Said differently: CALCULATE(SUM([Calendar date]);DATESBETWEEN([Calendar Working days];Sales order Created date;Treatment limit date)) = 3

Any idea?

 

I guess this is turning around DATEADD, CALCULATE,... but I don't get it 🙂

Thank you for your help,

Stéphane

1 ACCEPTED SOLUTION
Mariusz
Community Champion
Community Champion

Hi @Stéphane 

 

Try something like 

Column = 
VAR __date = 'Sales order'[Date]
VAR __tlb = FILTER( 'Calendar', 'Calendar'[Date] > __date &&  'Calendar'[Is Weekend] = FALSE() )
RETURN 
CALCULATE(
    MAX( 'Calendar'[Date] ),
    TOPN( 3, __tlb, [Date], ASC )
)

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
LinkedIn

 

View solution in original post

6 REPLIES 6
Mariusz
Community Champion
Community Champion

Hi @Stéphane 

 

Try something like 

Column = 
VAR __date = 'Sales order'[Date]
VAR __tlb = FILTER( 'Calendar', 'Calendar'[Date] > __date &&  'Calendar'[Is Weekend] = FALSE() )
RETURN 
CALCULATE(
    MAX( 'Calendar'[Date] ),
    TOPN( 3, __tlb, [Date], ASC )
)

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
LinkedIn

 

It works perfectly, thanks a lot!

Hi, thanks for your help!

First link is a smart way to solve the issue in a different way, I'll keep it it mind and use it if I don't manage to get something from the second one.

I'll keep you posted.

Greg_Deckler
Super User
Super User

Sample data would help. Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

 

I can't tell 100% exactly what you want, but these might help: See if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TIT...

 

Also

https://community.powerbi.com/t5/Quick-Measures-Gallery/Net-Work-Days/td-p/367362


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Thank you for your answer, here are some examples, unfortunately the links provided don't help it seems to me:

Sales order table:

20200408_Capture1.PNG

Calendar table:

20200408_Capture2.PNG

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.