Power Query / Formatting Date Time

Advertisements

Power Query is a powerful tool for manipulating and cleaning data, and it offers various features for managing dates. Here are some essential steps and techniques for handling date formats:

  • When you import data into Power Query, ensure that date columns have the correct data type. Sometimes Power Query’s automatic detection gets it wrong, so verify that all columns are correctly recognized as dates.
  • To change a specific column into a date format, you have several options:
    • Click the data type icon in the column header and select “Date.”
    • Select the column, then click Transform > Data Type > Date from the Ribbon.
    • Right-click on the column header and choose Change Type > Date.
    • You can also modify the applied data type directly in the M code to ensure proper recognition.
    • From a date column, you can extract various details using Power Query functions. These include:
      • Year
      • Days in the month
      • Week of the year
      • Day name
      • Day of the year
    Advertisements
    • To format dates in a specific way, you can use the Date.ToText function. It accepts a date value and optional parameters for formatting and culture settings.
    • Combine Date.ToText with custom format strings to achieve precise and varied date formats in a single line of code.
    • If you’re dealing with common formats like DD/MM/YYYY, MM/DD/YYYY, or YYYY-MM-DD, you can easily change the format:
      • Import your data into Power Query.
      • Select the date column to be formatted.
      • Right-click and choose Change Type > Date.
      • Select the desired predefined format (e.g., DD/MM/YYYY) and click OK.

      Remember, mastering date formatting in Power Query can significantly simplify your data processing tasks. Feel free to explore more advanced scenarios and create custom formats tailored to your needs!

      Advertisements

      تنسيق التاريخ والوقت Power Query

      Advertisements

      أداة قوية لمعالجة البيانات وتنظيفها Power Query يعد

      كما يوفر ميزات متنوعة لإدارة التواريخ فيما يلي بعض الخطوات والتقنيات الأساسية للتعامل مع تنسيقات التاريخ

      Power Query عند استيراد البيانات إلى

      تأكد من أن أعمدة التاريخ تحتوي على نوع البيانات الصحيح

      Power Query ففي بعض الأحيان يحدث خطأ في الاكتشاف التلقائي لـ

      لذا تحقق من أنه تم التعرف على جميع الأعمدة بشكل صحيح كتواريخ

      لتغيير عمود معين إلى تنسيق تاريخ لديك عدة خيارات

      Date  في رأس العمود وحدد Data Type انقر على أيقونة

      Date < Data Type< Transform   حدد العمود ثم انقر فوق

      Date < Change Type   انقر بزر الماوس الأيمن على رأس العمود واختر

      M يمكنك أيضًا تعديل نوع البيانات المطبق مباشرة في كود

      لضمان التعرف الصحيح

      من عمود التاريخ يمكنك استخراج تفاصيل متنوعة

      :وتشمل Power Query باستخدام وظائف

      Year

      Days in the month

      Week of the year

      Day name

      Day of the year

      Advertisements

      لتنسيق التواريخ بطريقة معينة

      Date.ToText يمكنك استخدام الدالة

      يقبل قيمة التاريخ والمعلمات الاختيارية لإعدادات التنسيق والثقافة

      Date.ToText قم بدمج

      مع سلاسل التنسيق المخصصة لتحقيق تنسيقات تاريخ دقيقة ومتنوعة في سطر واحد من التعليمات البرمجية

      إذا كنت تتعامل مع تنسيقات شائعة مثل

      DD/MM/YYYY

      MM/DD/YYYY

      YYYY-MM-DD

      فيمكنك تغيير التنسيق بسهولة

      Power Query قم باستيراد بياناتك إلى

      حدد عمود التاريخ المراد تنسيقه

      Date< Change Type انقر بزر الماوس الأيمن واختر

      حدد التنسيق المحدد مسبقًا المطلوب

      DD/MM/YYYY : على سبيل المثال

      OK وانقر فوق

      Power Query تذكر أن إتقان تنسيق التاريخ في

      يمكن أن يبسط مهام معالجة البيانات بشكل كبير لا تتردد في استكشاف تقنيات أكثر تقدماً وإنشاء تنسيقات مخصصة تناسب احتياجاتك

      Advertisements

      Leave a comment