Dax Function: LEFT

Category: Text Functions

The LEFT function in Power BI is a DAX text function that extracts a specified number of characters from the start (left) of a text string. It is primarily used for text manipulation, enabling users to retrieve substrings or truncate text to fit specific requirements.

Purpose

The LEFT function is designed to:

  1. Extract a substring starting from the first character of a text string.
  2. Facilitate text parsing, especially when working with data that includes prefixes, codes, or identifiers.
  3. Enhance text formatting and preparation for analysis.

Type of Calculations

  • Performs substring extraction based on character count.
  • Useful in cleaning, categorizing, and formatting text data for analysis.

Practical Use Cases

  • Extracting country or region codes from a concatenated string (e.g., “US12345”).
  • Truncating customer names or product descriptions for better display.
  • Parsing specific elements from formatted identifiers like “INV2025”.

LEFT(<text>, <num_chars>)</num_chars></text>

 
ParameterTypeDescription
textTextThe text string from which characters will be extracted. Can be a hardcoded string, column, or expression.
num_charsNumericThe number of characters to extract from the start of the string. Must be a positive integer.

 


How Does LEFT
 Dax Function Works

  1. The function identifies the starting point of the string (always the first character).
  2. Extracts the number of characters specified by the num_chars parameter.
  3. Returns the resulting substring.

If the num_chars parameter exceeds the length of the string, the function returns the entire text.

What Does It Return?

The function returns a text string containing the extracted substring.

When Should We Use It?

  • To extract meaningful segments from standardized text fields.
  • To truncate lengthy descriptions or names for improved visualization.
  • To split data fields into multiple components for detailed analysis.

Examples

Basic Usage – Extracting Prefix:


LEFT("Power BI", 5)

Result: "Power"

Column Usage:


ProductCodePrefix = LEFT(Products[ProductCode], 3)

Extracts the first three characters from the ProductCode column.
Example Result: "PRO" for ProductCode = "PRO123"

Advanced Usage – Combining with Other Functions:


ParsedData = LEFT(Sales[TransactionID], FIND("-", Sales[TransactionID]) - 1)

Extracts the portion of the transaction ID before the first hyphen.
Example Result: "2025" for TransactionID = "2025-INV-1234"

 

Tips and Tricks

  • Use with TRIM to ensure no leading spaces affect the result.
  • Combine with LEN and RIGHT to dynamically split strings from both ends.
  • Be cautious of empty or null values, as they return blank results.
  • Always validate num_chars to avoid unintended results or errors.

Performance Impact of LEFT DAX Function:

  • Efficient for small datasets and calculated columns.
  • For large datasets, consider preprocessing data externally to reduce strain on Power BI resources.

Related Functions You Might Need

  • RIGHT: Extracts characters from the end (right) of a string.
  • MID: Extracts characters from any position within a string.
  • LEN: Determines the length of a string.
  • FIND: Locates specific characters or substrings within a string.

Want to Learn More?
For more information, check out the official Microsoft documentation for LEFT You can also experiment with this function in your Power BI reports to explore its capabilities.

Unlock the full capabilities of Power BI and elevate your data insights with our specialized consulting services. Whether you need guidance on advanced DAX functions like those highlighted here, support in designing interactive dashboards, or expertise in optimizing data models for enhanced performance, our experienced Power BI consultants are equipped to deliver customized solutions for your business. Explore our Power BI Consulting Services page to discover how we can help your organization make smarter, data-driven decisions.

1. What does the LEFT function do in Power BI?

The LEFT function extracts a specified number of characters from the start of a text string.

2. Can the LEFT function handle numbers?

Yes, but numbers are first treated as text. Use FORMAT to convert numbers if needed.

3. What happens if num_chars is larger than the string length?

The function returns the entire string.

4. Can I use LEFT with null or blank values?

Yes, but the function will return a blank result for null or blank inputs.

5. How is LEFT different from MID?

LEFT always starts from the beginning of the string, while MID allows you to specify the starting point.