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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Anonymous
Not applicable

Column creation that extrapolates maximum

I need to make a custom column in power query. This excel formula =SE(E(N6>10; N6>T5); N6;T5), column N the table already has, however, column T would be the previous row of the column being created.

 

2 REPLIES 2
Stachu
Community Champion
Community Champion

This solution is based on the previous row reference as described here (excellent read):

https://www.thebiccountant.com/2018/07/12/fast-and-easy-way-to-reference-previous-or-next-rows-in-po...

let
    previousRow =  (MyTable as table, MyColumnName as text) =>
    let
        Source = MyTable,
        ShiftedList = {null} &  List.RemoveLastN(Table.Column(Source, MyColumnName),1),
        Custom1 = Table.ToColumns(Source) & {ShiftedList},
        Custom2 = Table.FromColumns(Custom1, Table.ColumnNames(Source) & {"Previous Row"})
    in
        Custom2,
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Jc27DQAxDALQXahdnJPLbxbL+68RTLonJCACDsNCWqBRW+rUkX7KP3EUXZzFJq6itKmXHapLrBo3xDoaj/U0kXkB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [N = _t, T = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"N", Int64.Type}, {"T", Int64.Type}}),
    Custom1 = previousRow(#"Changed Type","T"),
    #"Added Custom" = Table.AddColumn(Custom1, "Custom", each if ([N] > 10 and [N] > [Previous Row]) then [N] else [Previous Row])
in
    #"Added Custom"


Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

Anonymous
Not applicable

 

My question is how to create a column that repeats the value of created column row whenever it is greater than 10?

 

This table is an example of the question. The column N has values I have but the T is the column I need to create.

 

annacsac_0-1666012538811.png

 



Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

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