Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
BW40
Helper I
Helper I

Splitting one column into three columns using DAX

I have a combined field that has area, unit, and supervisor. I can split it in power query but it gets messy as some fields only have a unit name. I'm looking for IF( SEARCH("-") THEN SPLIT, else "unit" but that ignores the second hyphen. Also I do not think SPLIT is a DAX function.

 

column value: "area - unit - supervisor"

I want to generate seperate columns for area, unit, and supervisor.

 

Is there a dax function for splitting columns based on deliminators? It's a basic function in Tableau but trying to translate it into Power BI Dax

4 REPLIES 4
v-tianyich-msft
Community Support
Community Support

Hi @BW40 ,

 

Based on your description, I made simple samples and you can check the results as follows:

vtianyichmsft_0-1700117407374.png

 

DAX expression:

Area = VAR _CONTAIN = CONTAINSSTRING(MAX('Table'[Text]),"-")
VAR _PATHITEM = SUBSTITUTE(MAX('Table'[Text]),"-","|")
RETURN
IF(_CONTAIN,PATHITEM(_PATHITEM,1),"")

Unit = VAR _CONTAIN = CONTAINSSTRING(MAX('Table'[Text]),"-")
VAR _PATHITEM = SUBSTITUTE(MAX('Table'[Text]),"-","|")
RETURN
IF(_CONTAIN,PATHITEM(_PATHITEM,2),MAX('Table'[Text]))

Supervisor = VAR _CONTAIN = CONTAINSSTRING(MAX('Table'[Text]),"-")
VAR _PATHITEM = SUBSTITUTE(MAX('Table'[Text]),"-","|")
RETURN
IF(_CONTAIN,PATHITEM(_PATHITEM,3),"")

 

An attachment for your reference. Hope it helps!

 

Best regards,
Community Support Team_ Scott Chang

 

If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

 

chonchar
Helper V
Helper V

@BW40 

I have never done it, but I did find this post: 

 

https://community.fabric.microsoft.com/t5/Desktop/split-column-by-delimiter-in-dax/m-p/3129539#M1059...

 

Best of luck,

 

Cam

vanessafvg
Super User
Super User

in power query you can right click on a column and split by delimiter and other options.  It is also better from a performance perspective to create calculated columns in power query. 

 

if you need more help than that, i think you will need to provide a sample of your data (in text form) - it is quite difficult to provide a accurate solution without knowing what the data looks like.

 

https://support.microsoft.com/en-au/office/split-a-column-of-text-power-query-5282d425-6dd0-46ca-95b...





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




I found the simplest solution was to create two split by deliminiter functions in query. That allowed me to break up the fields but it would not allow me to create an IF condition. I had to create groups and do other manual clean up actions to get the data to an approximation of what is needed. It isn't exact but it is functional.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.