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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

Moving parts of a column

Hello everyone,

 

I'm new to power BI and power query and i'm blocking on something : i'm trying to move the content of a colum that is between two series of letters. For example, i'm trying to move the content between "DSY" to the column named "DSY" and do this with all the column to reorganise everything. 

I've tried with conditional column but can't go further and i don't understand 

Thank you for your help help.PNG

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

Hi, @Anonymous ;

You could add funtion as follows:

= List.PositionOf(#"Changed Type"[DSS],"DSY",2)
= List.Min(_postition)
= List.Max(_postition)
if List.PositionOf(#"Changed Type"[DSS],[DSS])>=_min and List.PositionOf(#"Changed Type"[DSS],[DSS])<=_max then [DSS] else null

The final show:

vyalanwumsft_0-1655714526541.png

The M language:

let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjU0UorViVYyMoIyTE3NTMEMMOESHAmRNjQyhDCMwZSZqSFCkZGxEYpiiDkmZiZKsbEA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [DSS = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"DSS", type text}}),
_postition=List.PositionOf(#"Changed Type"[DSS],"DSY",2),
_min=List.Min(_postition),
_max=List.Max(_postition),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if List.PositionOf(#"Changed Type"[DSS],[DSS])>=_min and List.PositionOf(#"Changed Type"[DSS],[DSS])<=_max then [DSS] else null
)
in
#"Added Custom"

Best Regards,
Community Support Team _ Yalan Wu
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

1 REPLY 1
v-yalanwu-msft
Community Support
Community Support

Hi, @Anonymous ;

You could add funtion as follows:

= List.PositionOf(#"Changed Type"[DSS],"DSY",2)
= List.Min(_postition)
= List.Max(_postition)
if List.PositionOf(#"Changed Type"[DSS],[DSS])>=_min and List.PositionOf(#"Changed Type"[DSS],[DSS])<=_max then [DSS] else null

The final show:

vyalanwumsft_0-1655714526541.png

The M language:

let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjU0UorViVYyMoIyTE3NTMEMMOESHAmRNjQyhDCMwZSZqSFCkZGxEYpiiDkmZiZKsbEA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [DSS = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"DSS", type text}}),
_postition=List.PositionOf(#"Changed Type"[DSS],"DSY",2),
_min=List.Min(_postition),
_max=List.Max(_postition),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if List.PositionOf(#"Changed Type"[DSS],[DSS])>=_min and List.PositionOf(#"Changed Type"[DSS],[DSS])<=_max then [DSS] else null
)
in
#"Added Custom"

Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.