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
Structuralguy
Frequent Visitor

Calculated column for duplicate timestamps based on a scaled reference row

I currently have a dataset which contains Generation and Performance data for unique Postcodes separated into half-hour timesteps spanning a two year period. I have Generation data for all Postcodes itemised as '61' and am looking to use this information to calculate Generation based on Performance values for the other Postcodes.

The data set looks like this:

Structuralguy_0-1649303441694.png

I am trying to calculate the Generation for Postcodes 60, 62, 63, 64... at each unique timestep using the formula:

Generation (for 62) = Generation (for 61) x Performance (62)/Performance(61)

i.e. Generation (for 62) = 10 x (23/70) = 3.29

 

Giving me a dataset which should look like this:

Structuralguy_1-1649303659117.png

Is it possible to achieve this? Any help would be greatly appreciated!

 

 

 

1 ACCEPTED SOLUTION
Vijay_A_Verma
Super User
Super User

Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test (later on when you use the query on your dataset, you will have to change the source appropriately)

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("dY9BDoAwCAS/Yjg3KSwWjV9p+v9vaIupiaEXDgwsQ61kTIkkI4OBTezi3kAv1NLDJeLH2GKfQJigM0Ejfn4X9ohbmfxvqO/xlaHOD8RiQ08oS0NPKEtD38fg7QY=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Postcode = _t, Timestamp = _t, Performance = _t, Generation = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Postcode", Int64.Type}, {"Timestamp", type datetime}, {"Performance", Int64.Type}, {"Generation", Int64.Type}}),
    #"Filtered Rows" = Table.SelectRows(#"Changed Type", each ([Postcode] = 61)),
    GoBack = #"Changed Type",
    #"Added Custom" = Table.AddColumn(GoBack, "TempGeneration", each #"Filtered Rows"{[Timestamp=[Timestamp]]}[Generation]),
    #"Added Custom2" = Table.AddColumn(#"Added Custom", "TempPerformance", each #"Filtered Rows"{[Timestamp=[Timestamp]]}[Performance]),
    #"Added Custom1" = Table.AddColumn(#"Added Custom2", "Custom", each if [Generation]=null then [TempGeneration]*[Performance]/[TempPerformance] else [Generation]),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom1",{"Generation", "TempGeneration", "TempPerformance"}),
    #"Rounded Off" = Table.TransformColumns(#"Removed Columns",{{"Custom", each Number.Round(_, 2), type number}}),
    #"Renamed Columns" = Table.RenameColumns(#"Rounded Off",{{"Custom", "Generation"}})
in
    #"Renamed Columns"

 

View solution in original post

1 REPLY 1
Vijay_A_Verma
Super User
Super User

Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test (later on when you use the query on your dataset, you will have to change the source appropriately)

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("dY9BDoAwCAS/Yjg3KSwWjV9p+v9vaIupiaEXDgwsQ61kTIkkI4OBTezi3kAv1NLDJeLH2GKfQJigM0Ejfn4X9ohbmfxvqO/xlaHOD8RiQ08oS0NPKEtD38fg7QY=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Postcode = _t, Timestamp = _t, Performance = _t, Generation = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Postcode", Int64.Type}, {"Timestamp", type datetime}, {"Performance", Int64.Type}, {"Generation", Int64.Type}}),
    #"Filtered Rows" = Table.SelectRows(#"Changed Type", each ([Postcode] = 61)),
    GoBack = #"Changed Type",
    #"Added Custom" = Table.AddColumn(GoBack, "TempGeneration", each #"Filtered Rows"{[Timestamp=[Timestamp]]}[Generation]),
    #"Added Custom2" = Table.AddColumn(#"Added Custom", "TempPerformance", each #"Filtered Rows"{[Timestamp=[Timestamp]]}[Performance]),
    #"Added Custom1" = Table.AddColumn(#"Added Custom2", "Custom", each if [Generation]=null then [TempGeneration]*[Performance]/[TempPerformance] else [Generation]),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom1",{"Generation", "TempGeneration", "TempPerformance"}),
    #"Rounded Off" = Table.TransformColumns(#"Removed Columns",{{"Custom", each Number.Round(_, 2), type number}}),
    #"Renamed Columns" = Table.RenameColumns(#"Rounded Off",{{"Custom", "Generation"}})
in
    #"Renamed Columns"

 

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.