Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
alinesilva2
Regular Visitor

text to date

Hello!
I need to change the variable of an api I'm working on from text to date, the code is in DAX, how do I do it?

2023-12-27_10h14_36.png

8 REPLIES 8
alinesilva2
Regular Visitor

I would like to create a variable that identifies the current date, in this case today, and another variable that is the date current -35 days, so that I can do an update automatically, but to do this I believe that I must first
being able to convert the Day field into date format and not Text It is currently in Text format

Fowmy
Super User
Super User

@alinesilva2 

What you are sharing is the "M" code in Power Query. The Date,ToText function is correct. Is question regarding how to do the same in DAX then

FORMAT ( Table[Date] , "yyyy-mm-dd" )



Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Hi!

 

I would like to create a variable that identifies the current date, in this case today, and another variable that is the date current -35 days, so that I can do an update automatically, but to do this I believe that I must first
being able to convert the Day field into date format and not Text It is currently in Text format

@alinesilva2 

Share some sample date format in text, I will show how to convert it.


Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

2023-12-27_10h14_36.png

My problem is in this part of the code

@alinesilva2 
Please provide explanation and the expected result

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

 

Currently I have a field called "DAY" and this field is configured as text type in my API (which is
my data source), I need to convert this field which is in the format YYYY-MM-DD (text) to DD/MM/YYY (date), as
This way I can automate my query.

Below is an example of one of my attempts to create these variables.

In this case, the period of time I need is from the day before the current day to 35 days before the current day, in order to have the
Automatic Update.

alinesilva2_0-1703786587237.pngalinesilva2_1-1703786611265.pngalinesilva2_2-1703786630459.png

 

@alinesilva2 

If you date is in text as yyyy-mm-dd then just chagne the data type to date:

Fowmy_0-1703829196522.png
You get the result

Fowmy_1-1703829239934.png

 




 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.