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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
thorrrr
Helper I
Helper I

DateError in Power Query when i close & Load

Everything worked fine inside PQ no errors reported, but whwen i close it i get not lading and Date Error.Everything worked fine inside PQ no errors reported, but whwen i close it i get not lading and Date Error. See image 

 

Code 

 

let

    Source = Folder.Files("G:\OneDrive\Documents\Excel Files\Anditsgone Excell and CSV Files\CSV Files\Magento Orders"),

    #"Removed Other Columns" = Table.SelectColumns(Source,{"Content", "Name", "Extension", "Date accessed", "Date modified", "Date created", "Attributes", "Folder Path"}),

    #"Combined Binaries" = Binary.Combine(#"Removed Other Columns"[Content]),

    #"Imported CSV" = Csv.Document(#"Combined Binaries",[Delimiter=",", Columns=114, Encoding=1252, QuoteStyle=QuoteStyle.Csv]),

    #"Promoted Headers" = Table.PromoteHeaders(#"Imported CSV"),

    #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"order_id", Int64.Type}, {"email", type text}, {"firstname", type text}, {"lastname", type text}, {"prefix", type text}, {"middlename", type text}, {"suffix", type text}, {"taxvat", type text}, {"created_at", type datetime}, {"updated_at", type datetime}, {"invoice_created_at", type datetime}, {"shipment_created_at", type datetime}, {"creditmemo_created_at", type datetime}, {"tax_amount", Int64.Type}, {"base_tax_amount", Int64.Type}, {"discount_amount", Int64.Type}, {"base_discount_amount", Int64.Type}, {"shipping_tax_amount", Int64.Type}, {"base_shipping_tax_amount", Int64.Type}, {"base_to_global_rate", Int64.Type}, {"base_to_order_rate", Int64.Type}, {"store_to_base_rate", Int64.Type}, {"store_to_order_rate", Int64.Type}, {"subtotal_incl_tax", type number}, {"base_subtotal_incl_tax", type number}, {"coupon_code", type text}, {"shipping_incl_tax", type number}, {"base_shipping_incl_tax", type number}, {"shipping_method", type text}, {"shipping_amount", type number}, {"subtotal", type number}, {"base_subtotal", type number}, {"grand_total", type number}, {"base_grand_total", type number}, {"base_shipping_amount", type number}, {"adjustment_positive", type number}, {"adjustment_negative", type number}, {"refunded_shipping_amount", Int64.Type}, {"base_refunded_shipping_amount", Int64.Type}, {"refunded_subtotal", type number}, {"base_refunded_subtotal", type number}, {"refunded_tax_amount", Int64.Type}, {"base_refunded_tax_amount", Int64.Type}, {"refunded_discount_amount", Int64.Type}, {"base_refunded_discount_amount", Int64.Type}, {"store_id", Int64.Type}, {"order_status", type text}, {"order_state", type text}, {"hold_before_state", type text}, {"hold_before_status", type text}, {"store_currency_code", type text}, {"base_currency_code", type text}, {"order_currency_code", type text}, {"total_paid", type number}, {"base_total_paid", type number}, {"is_virtual", Int64.Type}, {"total_qty_ordered", Int64.Type}, {"remote_ip", type text}, {"total_refunded", type number}, {"base_total_refunded", type number}, {"total_canceled", type text}, {"total_invoiced", type number}, {"customer_id", Int64.Type}, {"billing_prefix", type text}, {"billing_firstname", type text}, {"billing_middlename", type text}, {"billing_lastname", type text}, {"billing_suffix", type text}, {"billing_street_full", type text}, {"billing_city", type text}, {"billing_region", type text}, {"billing_country", type text}, {"billing_postcode", type text}, {"billing_telephone", type text}, {"billing_company", type text}, {"billing_fax", type text}, {"customer_id_1", Int64.Type}, {"shipping_prefix", type text}, {"shipping_firstname", type text}, {"shipping_middlename", type text}, {"shipping_lastname", type text}, {"shipping_suffix", type text}, {"shipping_street_full", type text}, {"shipping_city", type text}, {"shipping_region", type text}, {"shipping_country", type text}, {"shipping_postcode", type text}, {"shipping_telephone", type text}, {"shipping_company", type text}, {"shipping_fax", type text}, {"payment_method", type text}, {"product_sku", type text}, {"product_name", type text}, {"qty_ordered", Int64.Type}, {"qty_invoiced", Int64.Type}, {"qty_shipped", Int64.Type}, {"qty_refunded", Int64.Type}, {"qty_canceled", Int64.Type}, {"product_type", type text}, {"original_price", type number}, {"base_original_price", type number}, {"row_total", type number}, {"base_row_total", type number}, {"row_weight", type number}, {"price_incl_tax", type number}, {"base_price_incl_tax", type number}, {"product_tax_amount", Int64.Type}, {"product_base_tax_amount", Int64.Type}, {"product_tax_percent", Int64.Type}, {"product_discount", Int64.Type}, {"product_base_discount", Int64.Type}, {"product_discount_percent", Int64.Type}, {"is_child", type text}, {"product_option", type text}}),

    #"Removed Columns" = Table.RemoveColumns(#"Changed Type",{"prefix", "middlename", "suffix", "taxvat", "updated_at", "invoice_created_at", "shipment_created_at", "tax_amount", "base_tax_amount", "discount_amount", "base_discount_amount", "shipping_tax_amount", "base_shipping_tax_amount", "base_to_global_rate", "base_to_order_rate", "store_to_base_rate", "store_to_order_rate", "subtotal_incl_tax", "product_option", "base_subtotal", "base_grand_total", "refunded_tax_amount", "base_refunded_tax_amount", "refunded_discount_amount", "base_refunded_discount_amount", "store_id", "order_state", "store_currency_code", "base_currency_code", "order_currency_code", "base_total_paid", "is_virtual", "base_total_refunded", "customer_id", "billing_prefix", "billing_firstname", "billing_middlename", "billing_lastname", "billing_suffix", "billing_street_full", "billing_city", "billing_region", "billing_country", "billing_postcode", "billing_telephone", "billing_company", "billing_fax", "customer_id_1", "shipping_prefix", "shipping_firstname", "shipping_middlename", "shipping_lastname", "shipping_suffix", "shipping_street_full", "shipping_city", "shipping_region", "shipping_country", "shipping_postcode", "shipping_telephone", "shipping_company", "shipping_fax", "product_tax_amount", "product_base_tax_amount", "product_tax_percent", "product_discount", "product_base_discount", "product_discount_percent", "is_child", "email", "coupon_code", "base_shipping_incl_tax", "shipping_method", "shipping_incl_tax", "base_subtotal_incl_tax", "subtotal", "adjustment_positive", "adjustment_negative", "refunded_shipping_amount", "base_refunded_shipping_amount", "grand_total", "base_shipping_amount", "base_refunded_subtotal", "hold_before_state", "hold_before_status", "total_invoiced", "total_canceled", "payment_method", "product_type", "qty_invoiced", "qty_shipped", "qty_refunded", "qty_canceled", "base_original_price", "row_total", "base_row_total", "row_weight", "price_incl_tax", "base_price_incl_tax"}),

    #"Filtered Rows" = Table.SelectRows(#"Removed Columns", each ([order_id] <> null)),

    #"Removed Columns1" = Table.RemoveColumns(#"Filtered Rows",{"remote_ip"}),

    #"Capitalized Each Word" = Table.TransformColumns(#"Removed Columns1",{{"firstname", Text.Proper}}),

    #"Trimmed Text" = Table.TransformColumns(#"Capitalized Each Word",{{"firstname", Text.Trim}}),

    #"Cleaned Text" = Table.TransformColumns(#"Trimmed Text",{{"firstname", Text.Clean}}),

    #"Trimmed Text1" = Table.TransformColumns(#"Cleaned Text",{{"lastname", Text.Trim}}),

    #"Cleaned Text1" = Table.TransformColumns(#"Trimmed Text1",{{"lastname", Text.Clean}}),

    #"Capitalized Each Word1" = Table.TransformColumns(#"Cleaned Text1",{{"lastname", Text.Proper}}),

    #"Filtered Rows1" = Table.SelectRows(#"Capitalized Each Word1", each true)

in

 

    #"Filtered Rows1"

1 ACCEPTED SOLUTION

Hi @thorrrr,

 

If your date records are stored with "dd/mm/yyyy" format, you can use Date.From() function to format them to default format, then convert these columns to date type.

 

For example:

 

Table.

Capture.PNG

 

Try to direct convert the field to date:

Capture2.PNG

 

Add custom column to format the filed.

Formula:

AddCustom =Table.AddColumn(#"Changed Type", "Formted Column1", each Date.From([Column1],"uk"))

Capture3.PNG

 

Change type:

Capture4.PNG

 

Choose columns:

Capture5.PNG

 

Full query:

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjLQNzTUNzIwNFPSUQKyoOxYHaCUIZKUqb4FkowRsiYjfSNjqFwsAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}, {"Column2", type date}}),
    AddCustom =Table.AddColumn(#"Changed Type", "Formted Column1", each Date.From([Column1],"uk")),
    #"Format Date Fileds" = Table.TransformColumnTypes(AddCustom,{{"Formted Column1", type date}}),
    #"Choose columns" = Table.SelectColumns(#"Format Date Fileds",{"Formted Column1","Column2"})
in
    #"Choose columns"

 

 

 

In addition, you can also solve this issue by modify the "Locale" option, but if your data source contain multiple format of date, I'd like to suggest you use above function.

 

Capture6.PNG

 

Capture7.PNG

 

Capture8.PNG

 

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

3 REPLIES 3

Just a guess, but I noticed your date/time field [Created At] is in the day/month format.  Maybe there is a conflict with you regional settings.

Bit of a newbie how would I check this out?

Hi @thorrrr,

 

If your date records are stored with "dd/mm/yyyy" format, you can use Date.From() function to format them to default format, then convert these columns to date type.

 

For example:

 

Table.

Capture.PNG

 

Try to direct convert the field to date:

Capture2.PNG

 

Add custom column to format the filed.

Formula:

AddCustom =Table.AddColumn(#"Changed Type", "Formted Column1", each Date.From([Column1],"uk"))

Capture3.PNG

 

Change type:

Capture4.PNG

 

Choose columns:

Capture5.PNG

 

Full query:

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjLQNzTUNzIwNFPSUQKyoOxYHaCUIZKUqb4FkowRsiYjfSNjqFwsAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}, {"Column2", type date}}),
    AddCustom =Table.AddColumn(#"Changed Type", "Formted Column1", each Date.From([Column1],"uk")),
    #"Format Date Fileds" = Table.TransformColumnTypes(AddCustom,{{"Formted Column1", type date}}),
    #"Choose columns" = Table.SelectColumns(#"Format Date Fileds",{"Formted Column1","Column2"})
in
    #"Choose columns"

 

 

 

In addition, you can also solve this issue by modify the "Locale" option, but if your data source contain multiple format of date, I'd like to suggest you use above function.

 

Capture6.PNG

 

Capture7.PNG

 

Capture8.PNG

 

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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