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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Applicable88
Impactful Individual
Impactful Individual

Date function in nested If-statement, but changing after certain time

Hello,

I tried many ways to calculate  a dynamic time problem, but the calculated column in M language giving me trouble.

I use following if statement:

if ([deliverydate]<=Date.From(DateTime.LocalNow())or [deliverydate]=Date.AddDays(Date.From(DateTime.FixedLocalNow()), 1)) 
and ([Code]="Z" or [Status]="Y") and [Way]="TRE"and [CCode]<>"USA" then "Daily" else "Fail"

Ordernumber with a delivery of today or older  or orders of the next day  got returned "Daily" otherwise its a "Fail". 

 

The problem for example, that we are working all around the clock: From morning until 3PM there is only ordernumbers with today's or older delivery orders in the backlog which needs to be taken care of. At 3PM there is a reset and all the finished deliveries got deleted, but of course some are still not finished. So now correctly we have some leftover orders which has todays planned deliverydate, but also new orders of tomorrows date in the backlog. So far no problem, the second date function will return these orders. My problem is exactly after midnight, not only todays orders are returned, but also the orders of one day after, which only should be considered after the now next afternoons 3PM time.

 

Maybe someone already encountered this problem? 

Thank you in advanced.

Best.  

1 ACCEPTED SOLUTION
Applicable88
Impactful Individual
Impactful Individual

Found my solution. Defintely add another time function base on the system now() time where it compares what time of the time range it is at automatic dataset refresh.  So that it will use the right nested statement according to the time of today. 

View solution in original post

5 REPLIES 5
Applicable88
Impactful Individual
Impactful Individual

Found my solution. Defintely add another time function base on the system now() time where it compares what time of the time range it is at automatic dataset refresh.  So that it will use the right nested statement according to the time of today. 

amitchandak
Super User
Super User

@Applicable88 ,Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hello, 

maybe someone has a solution?

 

Sample Pbix File and Excel Sample Data is here. I also explained whats the problem: 

 

https://drive.google.com/drive/folders/1Iukm83AWa5hXDeqksfgqQoF-65_XNv2C?usp=sharing  

@amitchandak, I sent you the link to the sample data in your message inbox. 

Thank you.

Best. 

Hello @amitchandak

thank you very much, I will provide you a sample data for this. I will send you link in private message. Talk to you later. 

Best. 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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