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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
Sajil
New Member

Power Query Help

Hi Mates,

I am looking to get help with my data, i wish to add new columns for current value based on latest date per row and highest& lowest value from the table per row and their respective changes from the current value.

Sajil_0-1703760357683.png

 


The above is my date model, it shows my expected columns and results. 
Please for your consideration, i am using MS Office Standard 2019.

 


Appreciated your support , thank you.

1 REPLY 1
wdx223_Daniel
Community Champion
Community Champion

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("dY9BDsAgCAT/wlkTwCpy7Cd6Mf7/G8U0aWOV42SyE2gNzguRIAAjp0gcORsoQg+P48Xl1027YlCd3XDy7dLicN8UA0InKvOh6e+qE1WD4jSHq86hOj9x7Jr9Bg==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Item Code" = _t, Date = _t, Value = _t]),
    ChangedType = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Value", type number}}),
    Custom1 = Table.Group(
                          ChangedType,
                          "Item Code",
                          {
                           "n",
                           each let Rows=Table.RowCount(_),
                                    HighValue=List.Max([Value]),
                                    LowValue=List.Min([Value]),
                                    CurrentValue=List.Last([Value]),
                                    PreviousValue=List.Last(List.RemoveLastN([Value]),0)
                                in
                                    Table.FromColumns(
                                                      Table.ToColumns(_)
                                                      &List.Transform(
                                                                      {CurrentValue,
                                                                       HighValue,
                                                                       LowValue,
                                                                       CurrentValue-HighValue,
                                                                       (CurrentValue-HighValue)/CurrentValue,
                                                                       CurrentValue-LowValue,
                                                                       (CurrentValue-LowValue)/CurrentValue,
                                                                       PreviousValue,
                                                                       CurrentValue-PreviousValue,
                                                                       (CurrentValue-PreviousValue)/CurrentValue
                                                                      },
                                                                      each List.Repeat({_},Rows)
                                                                     ),
                                                      Table.ColumnNames(_)
                                                      &{
                                                        "CurrentValue",
                                                        "HighestValue",
                                                        "LowestValue",
                                                        "Change From HS",
                                                        "%",
                                                        "Change From LS",
                                                        "%2",
                                                        "Preivous Value",
                                                        "Change From PV",
                                                        "%3"
                                                       }
                                                     )
                          }
                         ),
    Custom2=Table.Combine(Custom1[n]),
    Custom3 = Table.Sort(Custom2,"Date")
in
    Custom3

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

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 Kudoed Authors