Open In App

Power BI Data Types

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.

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.

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.

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.

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.

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.

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.

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.

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



Data Type Icons in Data View

Column Information in Fields Pane

Data Type Formatting in the Modeling Tab

Data Type Functions and Transformations

Data Profiling

Handling Blanks, Empty Strings, and Zero Values

Handling Blanks

Handling Empty Strings

Handling Zero Values

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.

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.

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.


Article Tags :