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
Anonymous
Not applicable

Data type is wrong?

Hi guys! First of all Happy New Year.

 

I´m working on a report for my work which has a lot of projects with their respective last update on the database. I´m making a function that calculates the days since the last update. The problem is that I´m having negative numbers and inconsistencies.

 

The function for the Column " Days since Last Update" is: 

Days since Last Update = TODAY()-'TPA Portfolio'[Last Update Date]

 

It´s important to remark that the Last Update Date column is stated by PowerBI as a Text field and the format is DD/MM/YYYY (Argentinian date)

 

Capture.JPG

 

Thanks for your help...

1 ACCEPTED SOLUTION

Nowhere. It was just an example to illustrate the solution.

 

In your case, go to the Query Editor, select your column with textual dates and adjust the data type using Locale.

 

The video below illustrates how; it starts already in the Query Editor.

 

Here is the Query EditorHere is the Query Editor

 

 

 

Specializing in Power Query Formula Language (M)

View solution in original post

8 REPLIES 8
Interkoubess
Solution Sage
Solution Sage

Hi @Anonymous,

 

What about using the datediff function for this issue...

 

Let us know

Anonymous
Not applicable

Days since Last Update = DATEDIFF(TODAY(),'TPA Portfolio'[Last Update Date],DAY)

 

And I´m getting: In DATEDIFF function, the start date cannot be greater than the end date

 

I think the Power BI is messing between the date format of my PC (which is English format mm/dd/yyyy) and the format of the data base

Check the syntax of the DATEDIFF function.

 

The start date should be supplied first.

Specializing in Power Query Formula Language (M)
Anonymous
Not applicable

I dont think that the syntax is the problem. I'm guessing that the problem is on the date formats.

In that case you have more than 1 problem.

 

You can convert text dates to real dates in the Query Editor.

 

And still you need to provide the earlier date as the first parameter to DATEDIFF.

 

You may think otherwise, but the syntax is quite clear:

 

DATEDIFF(<start_date>, <end_date>, <interval>) 

You may consider providing more information if you want helpful help.

 

Specializing in Power Query Formula Language (M)

This query TPA Portfolio:

 

let
    Source = #table(type table[Last Update Date = text],{{"31/12/2017"}}),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Last Update Date", type date}}, "es-AR")
in
    #"Changed Type"

 

works fine with this custom column:

 

Days since Last Update = DATEDIFF('TPA Portfolio'[Last Update Date],TODAY(),DAY)

 

DateDIFF.png

 

 

Convinced?

Specializing in Power Query Formula Language (M)
Anonymous
Not applicable

First of all, I appreciate your help.

 

Where do I have to insert that syntax function? 

let
    Source = #table(type table[Last Update Date = text],{{"31/12/2017"}}),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Last Update Date", type date}}, "es-AR")
in
    #"Changed Type" 

 

Nowhere. It was just an example to illustrate the solution.

 

In your case, go to the Query Editor, select your column with textual dates and adjust the data type using Locale.

 

The video below illustrates how; it starts already in the Query Editor.

 

Here is the Query EditorHere is the Query Editor

 

 

 

Specializing in Power Query Formula Language (M)

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.