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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
Mtaberna
Frequent Visitor

split column by "|" NOT in Power Bi Query

Hi, I neet to split this column (1-PATH col)  in  n columns by a delimitator  ( | )

I know this can be easily made with power query but the column is a measure

 

LV split.PNG

 

First row result should be:

 

Column 1 INFORMESLV

Column2  CM_PATENTE

Column3  DEPRE

Column4  4227004100

 

Maximum columns = 9

Ideas ??

 

Thanks

6 REPLIES 6
v-yangliu-msft
Community Support
Community Support

Hi  @Mtaberna ,

I created some data:

vyangliumsft_0-1648524863828.png

Here are the steps you can follow:

1. Create calculated table.

Table 2 =
VAR Temp =
    ADDCOLUMNS ( 'Table', "@Parent", SUBSTITUTE ( 'Table'[1-PATH col], "|", "|" ) )
VAR NewColumns =
    ADDCOLUMNS (
        Temp,
        "@FirstLevel", TRIM ( PATHITEM ( [@Parent], 1, TEXT ) ),
        "@SecondLevel", TRIM ( PATHITEM ( [@Parent], 2, TEXT ) ),
        "@ThirdLevel", TRIM ( PATHITEM ( [@Parent], 3, TEXT ) ),
        "@FourthLevel", TRIM ( PATHITEM ( [@Parent], 4, TEXT ) )
    )
VAR Result =
    SELECTCOLUMNS (
        NewColumns,
        "Original", [1-PATH col],
        "First Level", [@FirstLevel],
        "Second Level", [@SecondLevel],
        "Third Level", [@ThirdLevel],
        "Fourth Level", [@FourthLevel]
    )
RETURN
    Result

2. Result:

vyangliumsft_1-1648524863829.png

Best Regards,

Liu Yang

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

Hi Liu

That worked fine.. in a new table......but is there any other way to create the COLUMNS in the same Original Table  ??

The thing is......I need everything in one table

Thanks

truptis
Community Champion
Community Champion

Hi, thanks for your response.

The thing is that the proposed solutions work for just 2 columns.

I have a max of 9 columns, delimited by this character =  |

 

I need DAX code to split everything inside the column and also consider the case where 1 , 2 or more columns could be empty

 

New Ideas ?

 

Thnks

Hi Liu

That worked fine.. in a new table......but is there any other way to create the COLUMNS in the same Original Table  ??

The thing is......I need everything in one table

Thanks

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

Check out the February 2024 Power BI update to learn about new features.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.