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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

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
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

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.

Top Solution Authors