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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
GabrielFLima
Frequent Visitor

Power Query Editor retrieves data from excel inconsistently, making it useless

I encountered a problem while importing data using the Power Query Editor and coultn't find anything even parcially related while searching for solutions:

I receive an Excel spreadsheet daily to make a report which has a couple Date fields and one Time field (representing a sum of hours).

 

Sometimes the Power Query Editor imports those columns as it usually does (considering them as numbers, which I can easily manipulate to get the desired results), but sometimes it imports the dates already formatted as dates (which would actually be good if the change didn't trigger an error) and the Time format gets imported as only ":01", rendering the whole column useless.

 

I haven't been able to identify anything that may cause it to import the data in one way or the other, and it seems to just happen randomly.

Here are the 2 ways the Dates get imported:

GabrielFLima_0-1707507683668.png

GabrielFLima_1-1707507895164.png

 

And here is how the Time column gets imported vs the original format in Excel (which is custom):

 

GabrielFLima_2-1707507987984.png

GabrielFLima_4-1707508551998.png

Excel:

GabrielFLima_3-1707508311932.png

 

I'd greatly appreciate if anyone can help me make the query work consistently, but especially to make it not import the Time data in such a way that renders it completely useless.

6 REPLIES 6
danextian
Super User
Super User

Hi @GabrielFLima ,

 

Could you kindly provide a sample Excel file along with the expected data types for each column? This would make it easier for us to provide assistance as it gives us something concrete to work with.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Hello @danextian


Here is a link to the sample Excel file. 

The columns' expected data types are:
"Name" - Text
"Month" - Date

"Date" - Date

"Num Hours" - Time

Sorry for the wait, had a couple of non-work days.

It appears that power query cannot read the custom time format in Excel which [hh]:mm. So I changed it to as below, set the initial data type to number before converting to time.

danextian_0-1707919455982.png

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

I figured it'd have something to do with the custom formatting, but what gave me hope of finding a solution that doesn't involve manually adjusting the original file is the fact that sometimes Power Query actually recognizes the values and show them as numbers (my original query used this before it changed the way it recognized the data).

There wouldn't be, by any chance, a way to adjust this detail via query? Because manually adjusting the file kinda defeats PQ's purpose haha.

EDIT: For some reason my sample file gets imported correctly as I want it to without me having to change the file (see screenshot). Each time I get a little more lost

GabrielFLima_0-1707921790222.png

 

That is a curious and confusing thing. Is it the same file you shared? Can you share you M code?





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Yeah, it's absolutely the same file, and now it's back to how it was originally...

 

Here's the (very simple) M code I used to test the sample, which started working as intended and today came back to the problem:

 

let
Fonte = Excel.Workbook(File.Contents("C:\Users\...\sample.xlsb"), null, true),
SAMPLE1 = Fonte{[Name="SAMPLE"]}[Data],
#"Cabeçalhos Promovidos" = Table.PromoteHeaders(SAMPLE1, [PromoteAllScalars=true]),
#"Tipo Alterado" = Table.TransformColumnTypes(#"Cabeçalhos Promovidos",{{"Name", type text}, {"Month", Int64.Type}, {"Date", Int64.Type}, {"Num Hours", type number}})
in
#"Tipo Alterado"

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.