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

Convert a text measure to a date time measure

Hi all,

 

I have a problem with my calendar table.

I create a max_date measure, and POWER BI undrestand it is a datetime value.

Same when I create a same_max_date_last_week = max_date - 7, and POWER BI undrestand it is a datetime value, too.

But when I create a same_max_date_last_month = DATEVALUE( EDATE( [max_date], -1 ) ) & " " & TIME ( 23,59,59), the POWER BI cannot undrestand it is a datetime value, only know the measure is a text value.

 

Please take a look at my screenshoot, and the file on the link below and give me some help.

(Sorry if I'm not good at English).

Many thank!

https://drive.google.com/open?id=1vKfr26yg0lTgJk1WMTY6QL-pT0iwocLR

2019-11-29_17-44-59.png

 

1 ACCEPTED SOLUTION

try like
 
CALCULATE( MAXx( ALLSELECTED( 'calendar'[Date] ), DATEADD('calendar'[Date_with_end_time_of_day],-1,MONTH) ) )

View solution in original post

5 REPLIES 5
amitchandak
Super User
Super User

If it is created as a measure, check if it can be created a column and data type can be changed in Model/table view under the modeling tab, once click on the column you will get the option.

 

Refer

 

https://community.powerbi.com/t5/Desktop/Changing-Data-Type-problem/td-p/58122

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks.

My Recent Blog - https://community.powerbi.com/t5/Community-Blog/Comparing-Data-Across-Date-Ranges/ba-p/823601

Thank for your help, but my problem is the measure cannot change to datetime value in Modeling tab.

May you download my file and have some looks?

@amitchandak 

I think is DateTime value only. I am able to apply format on same.

 

same_max_date_last_week = FORMAT( [max_date] - 7,"YYYY-MM-DD")

 

The measure can be formatted in outcome you want using format.  Alignment can be changed using field formatting.

Hi @amitchandak 

The max_date_same_last_week is OK, it known as a datetime value and I can format it at Modeling tab

But the problem is the max_date_same_last_month, when I use EDATE and add TIME(23,59,59) into the measure, the system cannot undrestand it is a datetime value.

try like
 
CALCULATE( MAXx( ALLSELECTED( 'calendar'[Date] ), DATEADD('calendar'[Date_with_end_time_of_day],-1,MONTH) ) )

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.