web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / How to fill null value...
Power Apps
Unanswered

How to fill null values in column with median value for each category?

(0) ShareShare
ReportReport
Posted on by

I have this table (there columns I need):

 

Screenshot 2024-03-28 123848.png

 

I need to replace null values in original_eur column with median value for each group (group columns are event_id and category).

 

let
Source = Csv.Document(File.Contents("E:\Kwork\Copy_Ticombo_parse_data.csv"),[Delimiter=";", Columns=40, Encoding=1251, QuoteStyle=QuoteStyle.None]),


#"Upper heads" = Table.PromoteHeaders(Source, [PromoteAllScalars=true]),


#"Changed types" = Table.TransformColumnTypes(#"Upper heads",{{"Name", type text}, {"id", type text}, {"entity_id", type text}, {"competition_name", type text}, ... etc }),


#"Add column with median values" = Table.AddColumn(#"Changed types", "median_values", each Table.SelectRows(
Table.Group(
#"Changed types",
{"event_id", "category"},
{"median", each List.Median(_[original_eur]), Int64.Type}
),
each _ = [event_id = "event_id", category = "category"]
))
in
#"Add column with median values"

 

At last step:

1) I make grouped table with medians;

At this stage all works.

But how select right value for each row?

 

 

 

Categories:
I have the same question (0)
  • JR-20121253-0 Profile Picture
    on at

    Please try the below:

    let
    Source = Csv.Document(File.Contents("E:\Kwork\Copy_Ticombo_parse_data.csv"),[Delimiter=";", Columns=40, Encoding=1251, QuoteStyle=QuoteStyle.None]),
    #"Upper heads" = Table.PromoteHeaders(Source, [PromoteAllScalars=true]),
    #"Changed types" = Table.TransformColumnTypes(#"Upper heads",{{"Name", type text}, {"id", type text}, {"entity_id", type text}, {"competition_name", type text}, ... etc }),
    #"Grouped for Median" = Table.Group(#"Changed types", {"event_id", "category"}, {"median", each List.Median([original_eur]), type nullable number}),
    #"Joined with Median" = Table.Join(#"Changed types", {"event_id", "category"}, #"Grouped for Median", {"event_id", "category"}, JoinKind.LeftOuter),
    #"Replaced Nulls" = Table.TransformColumns(#"Joined with Median", {"original_eur", each if _ = null then [median] else _, type nullable number}),
    #"Removed Median Column" = Table.RemoveColumns(#"Replaced Nulls",{"median"})
    in
    #"Removed Median Column"

    Group for Median: First, create a table grouped by event_id and category with the median of original_eur calculated for each group.

    Join with Median: Then, perform a left outer join of the original table with the median table on event_id and category. This step merges the median value into each corresponding row of the original dataset.

    Replace Nulls: After the join, use Table.TransformColumns to replace null values in the original_eur column with the corresponding median value.

    Remove Median Column: Finally, remove the temporary median column as it's no longer needed after replacing the null values.

     

    Thanks,

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 427 Most Valuable Professional

#2
11manish Profile Picture

11manish 201 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 128 Super User 2026 Season 2

Last 30 days Overall leaderboard