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

July 28 - August 9 | Final Round of the Power BI Dataviz World Championships. This is your chance. Learn more

Reply
left4pie2
Helper I
Helper I

Power Query Prefix Based on Another Column

left4pie2_0-1646163812792.png

My goal for this column is to split the two values up and subtract them. The problem is many of the values to the right of the "/" don't include the first two numbers. So for example 1945/60 should be abs(1945-1960) = 15

left4pie2_1-1646163976372.pngleft4pie2_2-1646163986975.png

I split these two columns up using the split column but now I need to use some logic to say if Face1.2 has < 4 characters add a prefix to Face1.2 from the left two characters of Face1.1

 

left4pie2_3-1646164424524.png

I tried to create the prefix with this line but I got an error that it didn't recognize the LEFT() function.

 

 

Thanks for the help!

 

1 ACCEPTED SOLUTION
v-yanjiang-msft
Community Support
Community Support

Hi @left4pie2 ๏ผŒ

According to your description, I have two methods.

Method1--In Power Query

1. Split Column by Delimiter.

vkalyjmsft_4-1646362698806.png

2. Split column Face1.1 by Position.

vkalyjmsft_5-1646362755187.png

3. Add a custom column.

=if Text.Length([Face1.2])<4 then[Face1.1.1]&""&[Face1.2]else[Face1.2]

4. Merge Face1.1.1 and Face1.1.2 columns, get the expected result.

vkalyjmsft_6-1646362926879.png

 

Method2--In DAX

1. In Power Query, split column by delimiter.

2. Change the data type of Face1.2 to Text.

vkalyjmsft_1-1646359773431.png

2. Create a calculated column in DAX.

Column =
IF (
    LEN ( 'Table'[Face1.2] ) < 4,
    CONCATENATE ( LEFT ( 'Table'[Face1.1], 2 ), 'Table'[Face1.2] ),
    'Table'[Face1.2]
)

Get the expected result.

vkalyjmsft_7-1646363334461.png

 

I attach my sample below for reference.

 

Best Regards,
Community Support Team _ kalyj

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

 

 

View solution in original post

2 REPLIES 2
v-yanjiang-msft
Community Support
Community Support

Hi @left4pie2 ๏ผŒ

According to your description, I have two methods.

Method1--In Power Query

1. Split Column by Delimiter.

vkalyjmsft_4-1646362698806.png

2. Split column Face1.1 by Position.

vkalyjmsft_5-1646362755187.png

3. Add a custom column.

=if Text.Length([Face1.2])<4 then[Face1.1.1]&""&[Face1.2]else[Face1.2]

4. Merge Face1.1.1 and Face1.1.2 columns, get the expected result.

vkalyjmsft_6-1646362926879.png

 

Method2--In DAX

1. In Power Query, split column by delimiter.

2. Change the data type of Face1.2 to Text.

vkalyjmsft_1-1646359773431.png

2. Create a calculated column in DAX.

Column =
IF (
    LEN ( 'Table'[Face1.2] ) < 4,
    CONCATENATE ( LEFT ( 'Table'[Face1.1], 2 ), 'Table'[Face1.2] ),
    'Table'[Face1.2]
)

Get the expected result.

vkalyjmsft_7-1646363334461.png

 

I attach my sample below for reference.

 

Best Regards,
Community Support Team _ kalyj

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

 

 

This worked! Thank you!

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon โ€“ Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save โ‚ฌ200 with code FABCMTY200.

Fabric Community Sticker Design Challenge Barcelona Carousel

Fabric Community Sticker Challenge - Barcelona 2026

If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!

July Power BI Update Carousel

Power BI Monthly Update - July 2026

Check out the July 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors