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
maracles
Resolver II
Resolver II

Column data type locked to Date

I have three tables.

1. Order Facts with a date column called First Published. This stores a date and Power BI, as expected, allows me to change the format on the modelling tab to whatever I want e.g. Whole Number.

2. Work Records with a date column called First AssignedThis stores a date and Power BI, as expected, allows me to change the format on the modelling tab to whatever I want e.g. Whole Number.

3. A link table called Unique Work Records. This is a two column table with all the unique work records by OrderID. This column is then used to link to the other two tables. The second column is First Assigned and is produced using a RELATED() function to extract the MIN([First Assigned]). Again, this stores a date and Power BI, as expected, allows me to change the format on the modelling tab to whatever I want e.g. Whole Number.

I have then created three measures:

 

 

  • First Assigned Date Max = MAX(Order Facts[First Assigned Date])

  • First Published Date Max = Max(Unique Work Records[First Published Date]

  • Time to Delegation = [First Published Date Max] - [First Assigned Date Max]


My goal is to have this final measure give the number of days between the other two dates and it does seem to work however it will only return the value as a date. When I go to the modelling ta for that measure I cannot select a different data type so I cannot show it as a whole number i.e. the number of days.

Can anyone help?

Thanks. 

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

Try adding a "*1" to your formula for the final measure and see if that helps:

 

Time to Delegation = ([First Published Date Max] - [First Assigned Date Max]) * 1

Or use DATEDIFF with an interval of DAYS:

https://msdn.microsoft.com/en-us/library/dn802538.aspx

 


@ 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...

View solution in original post

5 REPLIES 5
Greg_Deckler
Super User
Super User

Try adding a "*1" to your formula for the final measure and see if that helps:

 

Time to Delegation = ([First Published Date Max] - [First Assigned Date Max]) * 1

Or use DATEDIFF with an interval of DAYS:

https://msdn.microsoft.com/en-us/library/dn802538.aspx

 


@ 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...

@Greg_Deckler the "*1"  worked great. If you dn't mind, why does that work?

Thank you. 

Forces it to be returned as a number instead of a date type, basically in DAX data type logic: 

Date - Date = Date 

whereas 

Date * Number = Number

@ 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...

Very useful. Thanks. 

Forces it to be returned as a number instead of a date type, basically in DAX data type logic, Date - Date = Date whereas Date * Number = Number


@ 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...

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.