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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Vishruti
Helper I
Helper I

Clean Same Column with Multiple Conditions

I have following data

IMG_0197.jpeg

1. The blue fields have an extra dash at the end, which I want to remove

2. The orange cells have extra texts. I want to take the middle characters eg. ABC Ltd

3. The green field has an extra space before the text string, which I want to remove

 

If I apply one step to remove one error, the rest of the text is coming as blank

 

How can I achieve this data cleaning while retaining all values in the final column in Transform? I need to eventually build relationship with other tanle based on this column.

2 ACCEPTED SOLUTIONS
Ahmedx
Super User
Super User

Anonymous
Not applicable

Hi  @Vishruti ,

 

Here are the steps you can follow:

1. Create calculated column.

Result =
VAR _conditional1 =
    FIND ( "-", 'Table'[Site Name], 1, BLANK () )
VAR _originallen =
    LEN ( 'Table'[Site Name] )
VAR _conditional2_1 =
    FIND ( "->", 'Table'[Site Name], 1, BLANK () )
VAR _conditional2_1_result1 =
    IF (
        _conditional2_1 <> BLANK (),
        RIGHT ( 'Table'[Site Name], _originallen - 1 - _conditional2_1 )
    )
VAR _find2_2 =
    FIND ( "->", _conditional2_1_result1, 1, BLANK () ) + 1
VAR _conditional2_1_result2 =
    LEFT ( _conditional2_1_result1, LEN ( _conditional2_1_result1 ) - _find2_2 )
RETURN
    SWITCH (
        TRUE (),
        _originallen = _conditional1, LEFT ( 'Table'[Site Name], _originallen - 1 ),
        _originallen <> _conditional1
            && _conditional2_1 <> BLANK (), _conditional2_1_result2,
        [Site Name]
    )

vyangliumsft_0-1708499284115.png

2. Create calculated table.

new table =
DISTINCT('Table'[Result])

3. Result:

vyangliumsft_1-1708499284117.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

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi  @Vishruti ,

 

Here are the steps you can follow:

1. Create calculated column.

Result =
VAR _conditional1 =
    FIND ( "-", 'Table'[Site Name], 1, BLANK () )
VAR _originallen =
    LEN ( 'Table'[Site Name] )
VAR _conditional2_1 =
    FIND ( "->", 'Table'[Site Name], 1, BLANK () )
VAR _conditional2_1_result1 =
    IF (
        _conditional2_1 <> BLANK (),
        RIGHT ( 'Table'[Site Name], _originallen - 1 - _conditional2_1 )
    )
VAR _find2_2 =
    FIND ( "->", _conditional2_1_result1, 1, BLANK () ) + 1
VAR _conditional2_1_result2 =
    LEFT ( _conditional2_1_result1, LEN ( _conditional2_1_result1 ) - _find2_2 )
RETURN
    SWITCH (
        TRUE (),
        _originallen = _conditional1, LEFT ( 'Table'[Site Name], _originallen - 1 ),
        _originallen <> _conditional1
            && _conditional2_1 <> BLANK (), _conditional2_1_result2,
        [Site Name]
    )

vyangliumsft_0-1708499284115.png

2. Create calculated table.

new table =
DISTINCT('Table'[Result])

3. Result:

vyangliumsft_1-1708499284117.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

Ahmedx
Super User
Super User

pls try

Screenshot_4.png

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors