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
Thimios
Helper II
Helper II

Cannot use date column in measure

Hey all,

 

I have a very simple model, Date table & Data table. Data table has a Date type column. I need to create a measure calculating DATESDIFF or even DATESBETWEEN my date column and TODAY(). 

When writing the measure though, my date column is not available to use (actually only measures are available, not columns). Am I not getting something here as far as setup is concerned?

2 ACCEPTED SOLUTIONS
Payeras_BI
Super User
Super User

Hi @Thimios ,

 

The function expects a scalar value. 

Try by wrapping your date column with SELECTEDVALUE(), for instance.

 

If this post answered your question, please mark it as a solution to help other users find useful content.
Kudos are another nice way to acknowledge those who tried to help you.

J. Payeras
Mallorca, Spain

View solution in original post

PhilipTreacy
Super User
Super User

Hi @Thimios 

A measure using SELECTEDVALUE() as @Payeras_BI suggests will work.

Measure = DATEDIFF(SELECTEDVALUE('Table'[Date]),TODAY(),DAY)

tdy.png

Regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


View solution in original post

4 REPLIES 4
manikumar34
Solution Sage
Solution Sage

@Thimios , 

 

Take MAX or MIN o the date.

datediff = DATEDIFF(MAX(Sheet1[Date]),TODAY(),DAY)
 
Regards, 
Manikumar




If this helps, Appreciate your KUDOS!
Did I answer your question? Mark my post as a solution!


Proud to be a Super User!




PhilipTreacy
Super User
Super User

Hi @Thimios 

A measure using SELECTEDVALUE() as @Payeras_BI suggests will work.

Measure = DATEDIFF(SELECTEDVALUE('Table'[Date]),TODAY(),DAY)

tdy.png

Regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


PC2790
Community Champion
Community Champion

Hi @Thimios,

 

Try creating a calculated column using the below DAX formula:

 

Column = CALCULATE(COUNTROWS(DateTable),DATESBETWEEN(DateTable[Date],DateTable[Date],TODAY()))

 

Payeras_BI
Super User
Super User

Hi @Thimios ,

 

The function expects a scalar value. 

Try by wrapping your date column with SELECTEDVALUE(), for instance.

 

If this post answered your question, please mark it as a solution to help other users find useful content.
Kudos are another nice way to acknowledge those who tried to help you.

J. Payeras
Mallorca, Spain

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.