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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply

In a column if the value of a row is a name, then replace all the values below that row with null

In a table like the one below, I want to replace the values below the word "completed"

 

Col1Col2Col3
5Completed9
Completed1016
25Completed
682

 

So the result should be as below:

Col1Col2Col3
5Completed9
CompletedNull16
NullNullCompleted
NullNullNull

 

Any guide is appreciated. Thanks. 

2 REPLIES 2
camargos88
Community Champion
Community Champion

Hi @pouyanebrahimi ,

 

Try this mcode:

 

let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlXSUXLOzy3ISS1JTQGyLZVidaJRRAwNQIQZWNwIyETVARI1A4pYALGRUmwsAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Col1 = _t, Col2 = _t, Col3 = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Col1", type text}, {"Col2", type text}, {"Col3", type text}}),
ReplaceValues =
List.Transform(
Table.ColumnNames(#"Changed Type"),
each
let
_text = Table.ToList(Table.SelectColumns(#"Changed Type", _)),
_before = List.Range(_text, 0, List.PositionOf(_text, "Completed") + 1),
_after = List.Repeat({null}, List.Count(_text) - List.PositionOf(_text, "Completed") - 1)
in
List.Combine({_before, _after})
),
Table = Table.FromColumns(ReplaceValues)
in
Table

 

Capture.PNG



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



@camargos88  WoW! That was awesome! Thanks a lot!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.