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
niklasgrundel
Regular Visitor

Need help with DAX to measure days between to dates, with a twist

Hi,

 

I´m fairly new using PBI and Dax/Power Querys and has got stuck in a problem with a calculation . This is what I want to achive:

As you can see in picture below are there three columns, two of those handle order and delivery date. These two are just dates, no calculation. Column "C" should present days between order and delivery. I´ve managed to measure these days if both order and delivery date are filled in with this DAX-code: Days between order and delivery = ('TableName'[order date] - 'TableName'[delivery date])*1,

But here is the twist I mentioned in the subject line. 

- I want days to continue counting, and also be presented, even if delivery hasn´t been completed. Calculation(or measure) should use current day as input(e.g TODAY() in Dax). Look at example in row 3.

 

 

I´ve tried this code with no luck...

 

if ["delivery date"]=""
then (DateTime.Date-["order date"])
else
(["delivery date"]-["order date"])

 

Thanks for help in advance!

 

pbi_measure_days.jpg

1 REPLY 1
HotChilli
Super User
Super User

Have you posted this twice (it would be helpful if you remove the other post)

In DAX

Column = DATEDIFF(TableL[Delivery date] , if (ISBLANK(TableL[Order date]), TODAY(), TableL[Order date]),   DAY)

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.

Top Solution Authors