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
patricPBI
Helper I
Helper I

DateDiff only works with measure and does not recognize columns

Hi, 

 

As many others here, I would like to get the count difference of two dates. 

I have one column called "closed dates" and another column called "Opened Dates"

 

When I try to do the "duration.day" formular in the query editor, the outcome only shows me errors. 

When I try to do a dax measure with DateDiff it only allows me to select measures from that data table, but not simple columns. 

 

My two date columns are categorized as "Date" so that cannot be the problem. 

 

Is there a way to use the DateDiff function with normal date columns?

1 ACCEPTED SOLUTION

Hi @patricPBI ,

You have got extra COMMA for MAX function. Remove them please as highlighted below:

Pragati11_0-1600949634608.png

Thanks,

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

View solution in original post

8 REPLIES 8
Pragati11
Super User
Super User

Hi @patricPBI ,

 

Try a DAX measure something like this:

 

Diff = DATEDIFF(MAX(Date1), MAX(Date2), Month)

 

  1. Modify MAX to other summarisation as required.
  2. Replace Date1 and Date2 with your actual column names.

For details on DATEDIFF, refer following link:

https://docs.microsoft.com/en-us/dax/datediff-function-dax

 

Thanks,

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

Hi @Pragati11 ,

UNfortunetely, I get the following error message:

patricPBI_0-1600943448897.png

Also, for MAX, it is asking me fo a Scalar 2. What do I have to input here?

Best regards,

Patric

HI @patricPBI ,

 

Unfortunately, just the screesnhot of your error doesn't help.

Share screesnshot of the measure you are writing.

 

Thanks,

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

@Pragati11

patricPBI_0-1600943824143.png

What do I have to state where the "??" are?

Hello @patricPBI ,

The MAX function takes only one argument.

Check my DAX again.

Thank you

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

HI @Pragati11

patricPBI_0-1600946927278.png

It tells me that I cannot have just one argument for he MAX function

Hi @patricPBI ,

You have got extra COMMA for MAX function. Remove them please as highlighted below:

Pragati11_0-1600949634608.png

Thanks,

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

thanks a lot @Pragati11 

 

That was indeed the mistake. 

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.