Open In App

Power BI Data Types

Last Updated : 13 Dec, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

Data is the lifeblood of modern business, and harnessing its potential is crucial for informed decision-making. Microsoft Power BI is a powerful business intelligence tool that empowers organizations to turn raw data into actionable insights. To make this transformation, Power BI employs a variety of data types, each serving a unique purpose in the world of data analysis and visualization.

Introduction

In this comprehensive article, we will explore the diverse data types available in Power BI, their significance, their utility, and how they facilitate implicit and explicit data type conversion. We will also delve into handling blanks, empty strings, zero values, and special cases like image URLs and web URLs. Additionally, we will cover managing data type conversions and guide you on determining and specifying a column’s data type in Power Query Editor, Data View, or Report View.

Understanding Data Types in Power BI

Data types are the fundamental building blocks of any dataset in Power BI. They define the nature of the information contained within each column, facilitating data organization and analysis. Power BI supports a range of data types, each designed for a specific category of data. Let’s delve into these data types and understand their roles:

DATATYPE

DESCRIPTION

EXAMPLE

Decimal number

Decimal data types are essential for storing numbers with decimal points. They are indispensable for measurements, financial figures, and other precise calculations.

To calculate total charges of a product including tax (as a percentage), the numbers are usually not whole numbers.

Decimal

Fixed decimal number

The decimal separator is fixed in place for Fixed Decimal Number data types. There are always four digits to the right of the decimal separator, allowing for 19 significant digits.

Lets say we want to list the heights of all the students in a classroom. 2 decimal points of accuracy shall be enough.

decimal-point

Whole number

These data types store non-decimal numbers and are ideal for counting or indexing purposes.

Think of product IDs, employee numbers, or serial numbers.

whole

Percentage

Whether you’re analyzing financial statements or performing statistical calculations, the Percentage data type shines. It allows you to represent values as percentages, simplifying complex data analysis.

We use percentage in marks obtained in a test, composition of a product, relative humidity, etc.

Percentage

Date/Time

A Date/Time value is a combination of both a date and a time, and it’s internally represented as a Decimal number. This representation allows for seamless conversion between the two formats. The time component is stored as a fraction of 1/300 seconds (equivalent to 3.33 milliseconds) or as multiples of this fraction. This data type is designed to accommodate dates ranging from the year 1900 to the year 9999.

For tracking and visualizing events or transactions with both date and time components, like order timestamps.

Date

Date exclusively denotes a specific date without any associated time information. When represented within the model, it appears as a Date/Time value, but in this context, the fractional part is consistently set to zero, signifying the absence of any time component.

Used for representing calendar dates without time information, suitable for date-based analysis like daily sales.

Date

Time

Time solely conveys a time of day without any reference to a specific date. When it’s converted within the model, it assumes the form of a Date/Time value, and in this particular case, the part of the value to the left of the decimal point is consistently absent, emphasizing its exclusive focus on the time component.

Applied when you need to work with times of day independent of specific dates, like measuring response times.

Time

Date/Time/Timezone

Date/Time/Timezone signifies a UTC-based date and time along with a corresponding timezone offset. When this information is loaded into the model, it transforms into a Date/Time format. It’s important to note that the Power BI model remains consistent in displaying time regardless of a user’s geographical location or regional settings. For instance, a value like 09:00 entered into the model in the India will appear as 09:00 no matter where the report is accessed or viewed.

Useful for working with date and time data that includes timezone information, valuable for international reporting.

Duration

Duration indicates a specific length of time, and upon import into the model, it transforms into a Decimal Number type. In this numerical format, it becomes versatile, enabling you to perform addition and subtraction operations with Date/Time values, yielding accurate results. Additionally, Decimal Number representations of durations are conducive to being incorporated into visualizations that emphasize magnitude, providing a convenient way to showcase time-related data.

Appropriate for measuring the length of time intervals, like time spent on tasks or project durations.

Duration

Text

The Text data type is the repository for textual information, accommodating letters, numbers, and special characters. In Power BI, it’s commonly used for labels, descriptions, and textual data. The practical maximum limit for string length is approximately 32,000 Unicode characters, based on Power BI’s underlying Power Query engine, and its limits on text data type lengths.

Whether you’re working with product names, customer addresses, or employee names, the Text data type is your go-to choice.

Text

True/False (Boolean)

Boolean data types can have one of two values: True or False. They’re the foundation of conditional expressions and allow you to filter data based on specific conditions.

For representing binary, yes/no, or true/false data, often used in filtering or flagging records.

Binary

The Binary data type is used to store binary data, such as images, documents, or any non-textual information. While it may not be suitable for direct analysis, it serves as a storage mechanism for non-text data and is often used for purposes like document management and retrieval.

Utilized for storing binary data, like images, documents, or other non-text data in a binary format.

Data Type Detection in Query Editor

  • When you load data into Power BI, you can access the Query Editor by selecting “Edit Queries” during the data import process.
  • Inside the Query Editor, you can see the data types assigned to each column. Power BI typically tries to detect the data type automatically, but you can modify it if needed.

Screenshot-(9)

Data Type Icons in Data View

  • In the Data View section of Power BI, columns are represented with icons that reflect their data types.
  • For example, a calendar icon represents Date data, a clock icon represents Time data, a text icon represents Text data, and so on. These icons make it easy to identify the data type at a glance.

Column Information in Fields Pane

  • In the Fields pane, you can see the list of fields (columns) used in your report.
  • Hovering over a field name will display a tooltip with additional information, including the data type.

Data Type Formatting in the Modeling Tab

  • When you select a column in the Fields pane and navigate to the Modeling tab, you can format the data type explicitly. This is especially useful when you want to change the detected data type to something more suitable for your analysis.

Data Type Functions and Transformations

  • Power BI provides functions in DAX (Data Analysis Expressions) and Power Query for data type transformations. You can use these functions to explicitly convert or work with data types in calculations and transformations.

Data Profiling

  • In Power BI’s Query Editor, you can use the “Profile” feature to get insights into the distribution of data within a column, which can help you verify and understand data types.

Handling Blanks, Empty Strings, and Zero Values

Handling Blanks

  • Replace Missing Values: In Power Query Editor, you can replace blank values with a default value or another meaningful value using the “Replace Values” option. This ensures that your data is complete and doesn’t contain unexpected gaps.
  • Conditional Columns: You can create conditional columns using Power Query to handle blanks. For instance, if a value is blank, you can replace it with a predefined value.
  • DAX Functions: In DAX (Data Analysis Expressions), you can use functions like IF, ISBLANK, and COALESCE to handle blank values in calculations and measures.

Handling Empty Strings

  • Replace Empty Strings: Similar to handling blanks, you can use the “Replace Values” option in Power Query Editor to replace empty strings with a suitable value.
  • Conditional Columns: Create conditional columns to detect and replace empty strings with a value that makes sense in your context.
  • DAX Functions: In DAX, functions like IF and IFBLANK can be used to detect and replace empty strings in calculations.

Handling Zero Values

  • Transform in Power Query: In Power Query Editor, you can perform transformations on your data to handle zero values. For example, you can add a small value to zeros or use conditional logic to replace them with other values.
  • DAX Functions: In DAX, you can use functions like IF, SWITCH, and IFERROR to handle zero values in calculations and measures. For example, you can replace zeros with NULL or another appropriate value.
  • Conditional Formatting: In the Report View of Power BI, you can apply conditional formatting to zero values to make them more visually distinguishable or hide them altogether.

Leading and trailing sequences in Power BI

Leading and trailing spaces in Power BI are extra spaces that appear at the start or end of text values. They can cause data quality issues and affect sorting and grouping in visualizations. To address this, you can use Power Query’s text trimming functions (‘Text.Trim’, ‘Text.TrimStart’, and ‘Text.TrimEnd’) to remove these spaces during data cleaning. Be mindful of data modeling and visualization impacts, and encourage good data entry practices to prevent the introduction of such spaces.

Changing datatypes in Power BI

To change the data type of a column in Power BI, you can use the Power Query Editor.

  • First, open your Power BI report and access the Query Editor by clicking “Edit Queries” in the Home tab.
  • In the Query Editor, select the column you want to modify, navigate to the Transform tab, and choose a new data type from the Data Type dropdown. The column’s data type will be instantly updated.
  • Ensure that your data is compatible with the chosen data type; you might need to address any conversion issues prompted by the editor.
  • After making the changes, click “Close & Apply” to save the updates and load the modified data into Power BI.
  • You can then verify the new data type in the Data View to ensure it aligns with your reporting and visualization requirements. This process allows you to tailor your data for accurate analysis and presentation.

Screenshot-(9)

Capture

Changing multiple datatypes at a time in Power BI

In Power BI, you have the flexibility to change the data types of multiple columns simultaneously, which can save you time during the data preparation process.

  • To do this, access the Query Editor through the “Edit Queries” option in the Home tab. Once in the Query Editor, select the multiple columns you want to update by holding down the Ctrl key.
  • Then, navigate to the Transform tab, choose the new data type from the Data Type dropdown, and the change will be applied to all selected columns at once.
  • As always, it’s crucial to verify that the chosen data types are suitable for the content within each column to maintain data quality and accuracy.

Converting and casting Datatype using Power BI DAX formulae

In Power BI, you can use DAX (Data Analysis Expressions) formulas to convert or cast data from one data type to another. DAX provides several functions to help you achieve this. Here are some commonly used functions for data type conversion and casting in Power BI DAX:

CONVERT Function

The CONVERT function allows you to explicitly convert a value from one data type to another. For example, you can convert a numeric value to text or a date to a whole number.

Syntax: CONVERT(expression, target_data_type)

CAST Function:

The CAST function is similar to CONVERT and is used for explicit type casting. It’s often used when you want to cast a measure or column to a specific data type.

Syntax: CAST(expression AS data_type)

FORMAT Function:

The FORMAT function converts a value to text and allows you to specify a format code. It’s commonly used to format dates, times, or numbers for display.

Syntax: FORMAT(expression, format_code)

VALUES Function:

The VALUES function can be used to extract distinct values from a column, and it implicitly converts the column into a table.

Syntax: VALUES(column)

DATETIME Function:

The DATETIME function constructs a datetime value from separate year, month, day, hour, minute, and second components.

Syntax: DATETIME(year, month, day, hour, minute, second)

These DAX functions allow you to manipulate data types and perform explicit conversions or casting when needed for your calculations, measures, and visualizations in Power BI.

Managing Data Type Conversions

In the world of data analysis and visualization, choosing the right data types is paramount. Power BI offers a rich array of data types to accommodate diverse business needs. By understanding implicit and explicit data type conversion, handling missing or erroneous data, and working with special cases like image and web URLs, users can unlock the true power of Power BI. This tool transforms raw data into valuable insights that drive better decision-making, whether you’re working with text, numbers, dates, or even geographical data.

Handling Special Cases like Image URLs and Web URLs

In some cases, you may need to work with special data types, such as Image URL and Web URL. Image URL data types allow you to display images in your reports by providing the URL of the image hosted on the internet. Web URL data types facilitate the inclusion of clickable hyperlinks in your reports, providing users with the ability to navigate to external websites or access additional resources directly from your Power BI reports.

Conclusion

In the world of data analysis and visualization, choosing the right data types is paramount. Microsoft Power BI offers a rich array of data types to accommodate the diverse needs of businesses and analysts. By understanding the significance and utility of these data types, users can unlock the true power of Power BI, transforming raw data into valuable insights that drive better decision-making. Whether you’re working with text, numbers, dates, or even geographical data, Power BI’s versatile data types are your trusted companions on the journey to data-driven success.



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads