How To Split Columns By Delimiters In Power BI Using DAX

Data preparation is a crucial step in any Power BI project, and one of the most common challenges is dealing with columns that contain multiple values separated by delimiters. Whether you’re working with comma-separated names, pipe-separated categories, or any other delimiter-based data, knowing how to split columns using DAX can save you significant time and effort.

Understanding Column Splitting in Power BI

When working with data in Power BI, you’ll often encounter columns that contain multiple pieces of information separated by specific characters (delimiters). Common examples include:

  • Full names separated by spaces: “John Smith”
  • Email addresses with domains: “[email protected]
  • Product categories separated by commas: “Electronics,Laptops,Gaming”
  • Geographic data with pipes: “USA|California|Los Angeles”

While Power Query provides excellent tools for splitting columns during data transformation, there are scenarios where you need to split columns dynamically using DAX calculations.

When to Use DAX vs Power Query for Column Splitting

Use Power Query When:

  • You need to split columns permanently during data load
  • The split logic is straightforward and won’t change
  • You want to minimize model size and improve performance

Use DAX When:

  • You need dynamic splitting based on user selections
  • The splitting logic needs to be conditional
  • You want to maintain the original column while creating split versions
  • You’re working with calculated columns or measures

Basic DAX Functions for Column Splitting

Key DAX Functions

Before diving into examples, let’s understand the essential DAX functions for string manipulation:

  • LEFT(): Extracts characters from the left side of a string
  • RIGHT(): Extracts characters from the right side of a string
  • MID(): Extracts characters from the middle of a string
  • FIND(): Locates the position of a substring within a string
  • SUBSTITUTE(): Replaces specific text within a string
  • LEN(): Returns the length of a string

Method 1: Splitting Two-Part Strings

Let’s start with the most common scenario – splitting a full name into first and last names.

Example: Splitting Full Names

// Extract First Name
First Name = 
LEFT(
    Table[Full Name], 
    FIND(" ", Table[Full Name]) - 1
)

// Extract Last Name  
Last Name = 
RIGHT(
    Table[Full Name], 
    LEN(Table[Full Name]) - FIND(" ", Table[Full Name])
)

Handling Cases with No Delimiter

To make your DAX more robust, handle cases where the delimiter might not exist:

// Safe First Name extraction
First Name = 
IF(
    ISERROR(FIND(" ", Table[Full Name])),
    Table[Full Name],
    LEFT(Table[Full Name], FIND(" ", Table[Full Name]) - 1)
)

// Safe Last Name extraction
Last Name = 
IF(
    ISERROR(FIND(" ", Table[Full Name])),
    "",
    RIGHT(Table[Full Name], LEN(Table[Full Name]) - FIND(" ", Table[Full Name]))
)

Method 2: Splitting Multi-Part Strings

For columns with multiple delimiters, you’ll need more sophisticated DAX formulas.

Example: Extracting Email Components

// Extract Username from Email
Username = 
LEFT(
    Table[Email], 
    FIND("@", Table[Email]) - 1
)

// Extract Domain from Email
Domain = 
RIGHT(
    Table[Email], 
    LEN(Table[Email]) - FIND("@", Table[Email])
)

// Extract Domain Name (without extension)
Domain Name = 
VAR DomainPart = RIGHT(Table[Email], LEN(Table[Email]) - FIND("@", Table[Email]))
VAR DotPosition = FIND(".", DomainPart)
RETURN
    IF(
        ISERROR(DotPosition),
        DomainPart,
        LEFT(DomainPart, DotPosition - 1)
    )

Method 3: Advanced Splitting with Multiple Delimiters

For complex scenarios with multiple different delimiters, you can use SUBSTITUTE to standardize delimiters first:

// Standardize delimiters and extract first part
First Part = 
VAR StandardizedString = SUBSTITUTE(SUBSTITUTE(Table[Mixed Delimiters], "|", ","), ";", ",")
VAR FirstCommaPosition = FIND(",", StandardizedString)
RETURN
    IF(
        ISERROR(FirstCommaPosition),
        StandardizedString,
        LEFT(StandardizedString, FirstCommaPosition - 1)
    )

Method 4: Creating a Generic Split Function

For repeated use, create a more generic approach:

// Generic function to get the Nth element from a delimited string
Nth Element = 
VAR DelimitedString = Table[Categories]
VAR Delimiter = ","
VAR Position = 2  // Get the 2nd element
VAR AddDelimiter = Delimiter & DelimitedString & Delimiter
VAR StringLength = LEN(AddDelimiter)
VAR FirstOccurrence = FIND(Delimiter, AddDelimiter)
VAR SecondOccurrence = FIND(Delimiter, AddDelimiter, FirstOccurrence + 1)
VAR Result = 
    IF(
        Position = 1,
        MID(AddDelimiter, FirstOccurrence + 1, SecondOccurrence - FirstOccurrence - 1),
        // Add logic for other positions as needed
        ""
    )
RETURN Result

Method 5: Dynamic Column Splitting with Measures

Sometimes you need to split columns dynamically based on user selections:

Dynamic Split Result = 
VAR SelectedSplitType = SELECTEDVALUE(SplitOptions[Split Type])
VAR SourceColumn = SELECTEDVALUE(Table[Source Column])
RETURN
    SWITCH(
        SelectedSplitType,
        "First Name", LEFT(SourceColumn, FIND(" ", SourceColumn) - 1),
        "Last Name", RIGHT(SourceColumn, LEN(SourceColumn) - FIND(" ", SourceColumn)),
        "Domain", RIGHT(SourceColumn, LEN(SourceColumn) - FIND("@", SourceColumn)),
        "No Selection"
    )

Best Practices for Column Splitting with DAX

1. Error Handling

Always include error handling to prevent your reports from breaking:

Safe Split = 
VAR SplitResult = 
    IF(
        ISERROR(FIND(",", Table[Data])),
        Table[Data],
        LEFT(Table[Data], FIND(",", Table[Data]) - 1)
    )
RETURN
    IF(ISBLANK(SplitResult), "", SplitResult)

2. Performance Considerations

  • Use calculated columns for static splits that won’t change
  • Consider using measures for dynamic splits that depend on user interaction
  • Pre-process complex splits in Power Query when possible

3. Data Quality Checks

Implement validation to ensure your splits are working correctly:

Split Validation = 
VAR OriginalLength = LEN(Table[Original Column])
VAR SplitLength = LEN(Table[Part 1]) + LEN(Table[Part 2]) + 1  // +1 for delimiter
RETURN
    IF(OriginalLength = SplitLength, "Valid", "Check Required")

Common Use Cases and Solutions

1. Geographic Data Splitting

Country = LEFT(Table1[Location], FIND("|", Table1[Location]) - 1)
State = MID(Table1[Location], FIND("|", Table1[Location]) + 1, FIND("|", Table1[Location], FIND("|", Table1[Location]) + 1) - FIND("|", Table1[Location]) - 1)

2. Product Code Parsing

Product Category = LEFT(Table1[Product Code], 3)
Product ID = RIGHT(Table1[Product Code], LEN(Table1[Product Code]) - 4)

3. Date and Time Separation

Date Part = LEFT(Table1[DateTime], FIND(" ", Table1[DateTime]) - 1)
Time Part = RIGHT(Table1[DateTime], LEN(Table1[DateTime]) - FIND(" ", Table1[DateTime]))

Troubleshooting Common Issues

Issue 1: “A function ‘FIND’ has been used in a True/False expression”

Solution: Wrap FIND functions in ISERROR() when using in IF statements.

Issue 2: Blank Results

Solution: Check for empty strings and handle them explicitly:

Result = 
IF(
    OR(ISBLANK(Table1[SourceCol]), Table1[SourceCol] = ""),
    "",
    // Your split logic here
)

Issue 3: Performance Problems

Solution: Consider moving complex splitting logic to Power Query or use variables to avoid repeated calculations.

Conclusion

You’ve now learned how to split columns by delimiters in Power BI using DAX! This a powerful technique that provides flexibility for dynamic data manipulation. While Power Query remains the preferred method for static transformations, DAX splitting becomes invaluable when you need conditional logic, user-driven splits, or when working with calculated columns and measures.

Remember to always include proper error handling, test your formulas with various data scenarios, and consider performance implications when choosing between DAX and Power Query approaches. With these techniques and best practices, you’ll be able to handle even the most complex column splitting requirements in your Power BI reports.

Start with simple two-part splits and gradually work your way up to more complex scenarios. The key is understanding how the basic string functions work together and building robust formulas that can handle edge cases in your data.

Keywords: How To Split Columns By Delimiters In Power BI Using DAX

power bi cross selling matrix for retail

Market Basket Analysis in Power BI Cross Selling Matrix For Retail

A cross selling matrix in Power BI is a vital tool for the retail industry, enabling you to visualize and analyze which products are frequently purchased together by the same customers. This type of analysis—also known as market basket analysis—delivers powerful insights that can guide promotions, product placements, and inventory decisions.

Building a Retail Cross Selling Matrix in Power BI

A cross selling matrix helps retailers answer a simple but valuable question: “If a customer buys Product A, how likely are they to also purchase Product B during the same period?” Understanding these patterns allows stores to design smarter upselling strategies and create effective bundles that boost both sales and customer satisfaction.

How It Works

At its core, a cross selling matrix works by tracking customer purchase data to find common purchase combinations. You’ll essentially compare all pairs of products to count the number of unique customers who bought both products in a selected time frame.

Step-by-Step Approach

  1. Prepare the Data Model
  • Ensure you have sales transactions that include at least a product identifier and a customer identifier.
  • Build a product list (dimension) table and a separate transactions (fact) table in your model.
  1. Generate Customer Lists for Each Product
  • For any product, use DAX to create a list (virtual table) of customers who bought it.
  • Do the same for each comparison product in the matrix—these are your “row” and “column” products.
  1. Find Overlaps Using DAX Table Functions
  • Use DAX functions like VALUES() to pull the relevant customer lists.
  • Compare the two lists for every product pair using the INTERSECT() function to find customers who purchased both.
  • The count of intersecting customers is used to populate each matrix cell.
  1. Virtual Relationships for Comparison
  • If your comparison product table isn’t physically connected to the sales table, use TREATAS() within CALCULATETABLE() in DAX to virtually relate them during the comparison.
  • Remove existing context with ALL() where necessary to correctly isolate each calculation.
  1. Dynamic Filtering
  • The matrix remains interactive—choosing different dates or store locations will update results in real time.
  • This adaptability is powerful for seasonality and promotional period analysis.

Example DAX Snippet

Both Products Purchased = 
VAR CustomersProductA = VALUES(Sales[CustomerID])
VAR CustomersProductB = 
    CALCULATETABLE(
        VALUES(Sales[CustomerID]), 
        TREATAS(VALUES(CompareProducts[ProductID]), Sales[ProductID])
    )
RETURN
    COUNTROWS(INTERSECT(CustomersProductA, CustomersProductB))

Adjust table and column names to match your model.

power bi cross selling matrix for retail

Why Retailers Should Use a Power BI Cross Selling Matrix for Retail

  • Optimize Product Placement: Place complementary products near each other to encourage higher basket values.
  • Design Targeted Promotions: Offer discounts or bundles based on frequent purchase pairs.
  • Improve Inventory Management: Stock popular product pairings together to meet customer demand.
  • Enhance Customer Experience: Personalize recommendations for shoppers by suggesting common cross-sells.

Harnessing this approach will empower your retail business to make data-driven merchandising decisions, resulting in increased sales and improved customer loyalty. With a few dynamic DAX formulas and the robust visualization capabilities of Power BI, any retailer can unlock the value hidden in their sales data.

keywords: Power BI Cross Selling Matrix for Retail, Market Basket Analysis in Power BI

lookup last invoice date

Lookup Last Payment Date in Excel: Master Five Solutions for Any Version

When managing invoices and payments, one powerful Excel technique is to quickly lookup the last payment date for each invoice. Whether reconciling accounts or tracking customer payments, knowing the latest payment date is crucial. This tutorial explains five robust ways to achieve an Excel lookup last payment date for any Excel version—from legacy releases to Microsoft 365—so you can use the best method for your workflow.

Lookup Last Payment Date – Why This Functionality Works Well in Excel

Finance teams, small businesses, and freelancers often need a dynamic way to find the most recent payment date by invoice or customer. Manual solutions are slow and error-prone, but Excel’s built-in and advanced formulas let you automate the process reliably.

Method 1: MAXIFS Function (Excel 2016+)

The MAXIFS function delivers the maximum date that matches a given criterion, making it perfect for this lookup scenario1.

How to use:

  • Max Range: The date column.
  • Criteria Range: The invoice column.
  • Criteria: The specific invoice number.

Example:

text=MAXIFS(DateColumn, InvoiceColumn, InvoiceCell)
  • This formula scans all dates and returns the latest date for the matching invoice.

Tip: Use absolute references for the ranges and a relative reference for the criteria to fill the formula down your list efficiently.

Method 2: MAXIFS Spilled Array Solution (Excel 365)

If you have Excel 365 and want to lookup multiple invoices, you can leverage spilled array formulas for a one-formula-down-the-column approach. This is a very flexible solution because the both the lookup list and the invoice data can grow and you never have to update the formula (if it is setup dynamically).

How to use:

=MAXIFS(DateColumn, InvoiceColumn, InvoiceList)
  • The formula outputs the last payment date for every unique invoice in InvoiceList.
  • No manual copying or dragging needed—just one formula that updates dynamically.

Method 3: Excel Table + Dynamic Formulas

Lookup Last Payment Date

Convert your data to an Excel Table (Ctrl+T), name it (e.g., “PaymentTbl”), and use structured references. This is my most preferred method of handling any data in any scenario where it’s possible.

Advantages:

  • Automatically updates when new payments or invoices are added.
  • Combine with spilled array or lookup formulas for continuous reporting.
  • Creates and anchor point – you can easily reference the table columns and data by name from anywhere in your workbook (or even other workbooks).

Method 4: PivotTable (Any Excel Version)

Lookup Last Payment Date PivotT
able

For a no-formula, robust solution, create a PivotTable:

  • Place Dates and in Rows and order the dates descending.
  • You could also place Invoice in Rows, Date in Values (set to Max).
  • Instantly shows the latest payment per invoice.
  • Refresh when new data is added1.

Alternate Method for Older Excel Versions: AGGREGATE Function (Excel 2010+)

If for some reason your version doesn’t have MAXIFS, AGGREGATE is an excellent alternative with built-in LARGE and MAX options plus error handling1.

How to use:

=AGGREGATE(14, 6, DateColumn / (InvoiceColumn = InvoiceCell), 1)
  • Function 14 is LARGE; option 6 ignores errors.
  • This formula divides date values by a logical test, producing errors for non-matches (which are ignored).
  • Returns the largest (latest) date matching the invoice.

Key Takeaways: Excel Lookup Last Payment Date

  • MAXIFS is fastest for Excel 2016/Office 365 and newer.
  • AGGREGATE works well for older Excel versions and advanced users.
  • Spilled arrays (Excel 365) allow a single formula for all invoices.
  • Tables make reporting dynamic as your list grows.
  • Pivot Tables offer a no-code, universal alternative.

Each method lets you efficiently solve “how to lookup last payment date in Excel” with the right formula for your version and skills.

Ready to streamline your financial reporting? Try these techniques to automate your workflow and never miss another last payment date in Excel!

keywords: excel lookup last payment date, find last payment date in Excel, lookup last date by invoice Excel, Excel formula latest payment date, payment lookup solutions.

Microsoft fabric free; Fabric free trial

Should I Upgrade to a free Microsoft Fabric Trial?

If you are exploring Microsoft Fabric and encounter the message “Upgrade to a free Microsoft Fabric Trial” despite already having workspace capacity, here’s what you need to know. This common confusion happens because certain Microsoft Fabric features, especially preview ones like SQL databases and AI Skills, require tenant-level preview feature enablement—even if your workspace is already on a Premium or Fabric capacity.

Why Does Microsoft Fabric Ask for a Free Trial?

When trying to create a SQL database or an AI skill (preview) inside Microsoft Fabric, some users see a prompt requiring them to “Upgrade to a free Microsoft Fabric Trial.” This happens because these preview features are disabled by default at the tenant level for the entire organization. Even if your workspace has an assigned capacity (Premium or Fabric), you need administrator privileges to explicitly enable these preview features.

How to Enable Microsoft Fabric Preview Features

If you are an admin, here’s what to do:

  1. Go to the Microsoft Fabric admin portal.

  2. Look for tenant settings related to preview features.

  3. Enable SQL Database (preview) and AI Skills (preview).

  4. Wait a few minutes (usually between 3 to 15 minutes) for the changes to take effect.

After enabling these settings, you can create a SQL database or AI skill in your workspace without the need to upgrade or start a new trial.

This step is essential because Microsoft Fabric treats these preview features separately from your existing capacity licensing. The message asking to upgrade to a free trial is somewhat misleading—it really means “You need tenant-level preview feature enablement.” This key insight was highlighted by Adam Saxton from Guy in a Cube in his video explanation.

Quick Links to Get Started with Microsoft Fabric Features

Summary and Best Practices

  • Microsoft Fabric preview features like SQL databases and AI Skills require explicit tenant enablement.

  • Even if you have Premium or Fabric capacity, these features are disabled by default for your organization.

  • Admins must enable preview features in the admin portal for users to access them.

  • The free Fabric trial message is a prompt triggered due to disabled preview features, not an actual lack of capacity.

  • After enabling the settings, wait a few minutes before the features become available.


By understanding this distinction, you can avoid confusion and start leveraging Microsoft Fabric’s powerful capabilities without unnecessary trial upgrades. For more tips and updates on Microsoft Fabric and Power BI, follow the community experts and stay tuned for new videos and tutorials.

keywords: Microsoft Fabric freeMicrosoft Fabric trialMicrosoft Fabric preview features, and Microsoft Fabric SQL database.

Feel free to share your questions or experiences with Microsoft Fabric preview features in the comments!

If you’re ready to dive deep into Microsoft Fabric and its rich capabilities, start creating your first SQL database or AI skill today using the official docs linked above. Unlock the full potential of your data analytics journey!

 

 

 

 

extract linked workbook

How to Extract Linked Workbook Info from a Formula and Add Hyperlinks Automatically Using VBA in Excel

If you work extensively with Excel, you’ve likely faced formulas that link to external workbooks. Managing and understanding these links can be tricky, especially when you need to extract the workbook’s name or path and create easy navigation through hyperlinks.

In this blog post, you’ll learn how to use a simple yet powerful VBA macro to automatically extract linked workbook information from a formula and add a clickable hyperlink to it. This method streamlines workbook management and enhances spreadsheet navigation. You can quickly see what workbook is being referenced, and if you need to, you can quickly click the link to open it up. No need to go into the Workbook Links panel and click around, which can be challenging if you have several links.

Why Extract Linked Workbook Info and Create Hyperlinks?

Excel formulas that reference external workbooks usually contain the linked workbook’s path and filename in the formula text, like:

text='C:\Users\UserName\Documents\[SalesData.xlsx]Sheet1'!A1

Manually parsing these formulas to find the linked workbook name and create hyperlinks can be tedious. Automating this process helps:

  • Quickly identify all linked files
  • Avoid broken or outdated links
  • Improve navigation within your workbook
  • Save time in auditing external references
extract linked workbook

Here’s the VBA code we’ll use to extract the linked workbook name from a formula in cell A1, store that info in cell B1, and create a clickable hyperlink in cell C1:

Dim wbName As String
Dim cellFormula As Range

Set cellFormula = ws.Range("A1")
fText = cellFormula.Formula

startPos = InStr(fText, "[")
endPos = InStr(fText, "]")

If startPos > 1 Then
filePath = Mid(fText, 2, startPos - 2)
filePath = Replace(filePath, "'", "") ' remove single quotes

wbName = Mid(fText, startPos + 1, endPos - startPos - 1)
wbName = Replace(wbName, "[", "")
wbName = Replace(wbName, "]", "")

Debug.Print filePath & wbName
ws.Range("B1").Value = filePath & wbName
ws.Hyperlinks.Add Anchor:=ws.Range("C1"), _
Address:=filePath & wbName, _
TextToDisplay:=wbName
End If

Breaking Down the Code Step-by-Step

1. Define the Target Cell and Get the Formula

textSet cellFormula = ws.Range("A1")
fText = cellFormula.Formula
  • We focus on cell A1 in the worksheet ws.
  • We grab the entire formula from this cell as a string for processing.

2. Locate the Workbook Name within the Formula

textstartPos = InStr(fText, "[")
endPos = InStr(fText, "]")
  • The workbook name is enclosed in square brackets [WorkbookName.xlsx].
  • InStr finds the position of these brackets in the formula text.

3. Extract the File Path

textfilePath = Mid(fText, 2, startPos - 2)
filePath = Replace(filePath, "'", "")
  • Extract the file path, which usually precedes the [.
  • Remove any single quotes to keep the path clean.

4. Extract and Clean the Workbook Name

textwbName = Mid(fText, startPos + 1, endPos - startPos - 1)
wbName = Replace(wbName, "[", "")
wbName = Replace(wbName, "]", "")
  • Extract the workbook name between the brackets.
  • Remove any remaining brackets for a clean filename.

5. Output the Combined Path and Workbook Name

textDebug.Print filePath & wbName
ws.Range("B1").Value = filePath & wbName
  • Print the full file path combined with the workbook name in the Immediate Window (useful for debugging).
  • Also store this combined string in cell B1.

6. Create a Hyperlink to the Workbook

textws.Hyperlinks.Add Anchor:=ws.Range("C1"), _
    Address:=filePath & wbName, _
    TextToDisplay:=wbName
  • Add a hyperlink in cell C1.
  • The link points to the extracted full path of the linked workbook.
  • The link text displays the workbook name for clarity.

How to Use This VBA Macro in Your Workbook

  1. Open the Visual Basic for Applications editor (Press Alt + F11 in Excel).
  2. Insert a new module: Right-click your workbook in the Project explorer, select Insert > Module.
  3. Copy and paste the code inside a Sub procedure, making sure you define ws properly
  4. Run the macro or assign it to a button for quick execution.
  5. Check cells B1 for the extracted link and C1 for the clickable hyperlink.
Dim wbName As String
Dim cellFormula As Range

Set cellFormula = ws.Range("A1")
fText = cellFormula.Formula

startPos = InStr(fText, "[")
endPos = InStr(fText, "]")

If startPos > 1 Then
filePath = Mid(fText, 2, startPos - 2)
filePath = Replace(filePath, "'", "") ' remove single quotes

wbName = Mid(fText, startPos + 1, endPos - startPos - 1)
wbName = Replace(wbName, "[", "")
wbName = Replace(wbName, "]", "")

Debug.Print filePath & wbName
ws.Range("B1").Value = filePath & wbName
ws.Hyperlinks.Add Anchor:=ws.Range("C1"), _
Address:=filePath & wbName, _
TextToDisplay:=wbName
End If

Tailoring This Code for Your Needs

  • Range flexibility: Loop through multiple cells with formulas and automate link extraction and hyperlink creation for all.
  • Error handling: Add more robust checks for broken links or non-standard formula formats.
  • User interface: Create a user form that lets users pick ranges or sheets interactively.
  • Dynamic output: Write results to a dedicated worksheet listing all external links in your workbook.

Conclusion

Automating the process to extract linked workbook information from formulas and creating hyperlinks with VBA can significantly increase your workbook management efficiency. Whether auditing external links or creating easy navigation across related files, this VBA snippet provides a solid foundation.

Try enhancing this script by adapting it to your specific workbook structures and enjoy smoother workflows in Excel.

keywords to help others find this post: extract linked workbook, hyperlinks, getting linked workbook info


Do You Need Personalized Help and Custom Solutions?

I have been called a guru and hero more times than I can count, as I am a great listener and truly have a knack for asking the right questions to understand unique business challenges. I am very passionate about crafting tools and processes that work for users of all levels and experience. 

Reach out today and let’s discuss how I can help you and your business!

I also offer one-on-one tutoring for customized learning and upskilling. Visit my consulting page and send a message if you are interested.

Other Resources

Also, consider checking out some great resources on Amazon Disclosure: this is an affiliate link, so I may earn a small commission if you decide to make a purchase which will help cover the cost of hosting this website. 

Please bookmark and subscribe!  I am actively working on adding new, relevant content to help others out! Thanks so much!

Subscribe via Email and Stay Up to Date!

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

If I helped you, please consider leaving a tip via PayPal to support the blog! Thanks!!

Thanks so much for supporting my blog and for helping others too!