1

I'm working in Power BI and I have the below table of how it is and how I want it to look, with the highlighted green cells what I'm looking to change:

enter image description here

I want to fill in the null values with the company name if that data exists on another row. Take John for example, I want to fill in the null value in row 3 because I have another row with John and company is filled out. But for Tim, Dave and Andy they only have one record so I need to keep that record as null.

I'm trying to do this in Transform Data, but not sure if that's the best place to accomplish this.

Any suggestions on how to handle this would be greatly appreciated.

1
  • Did any of these answers work for you? If so, please toggle checkmark to accept that solution for your question Commented Aug 28, 2023 at 12:35

2 Answers 2

1

Please don't paste pictures of data.

enter image description here

let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Name", type text}, {"Company", type text}, {"Sales", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Company Fixed", (x)=> let
        a = Table.SelectRows(#"Changed Type", each _[Name] = x[Name]),
        b = try List.Distinct(List.RemoveNulls(a[Company])){0} otherwise null
        in b)
in
    #"Added Custom"

Add a custom column and type in the following:

(x)=> let
a = Table.SelectRows(#"Changed Type", each _[Name] = x[Name]),
b = try List.Distinct(List.RemoveNulls(a[Company])){0} otherwise null
in b
Sign up to request clarification or add additional context in comments.

Comments

0

You could also merge the data on top of itself

let Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Merged Queries" = Table.NestedJoin(Source, {"Name"}, Table.Distinct(Table.SelectRows(Source, each [Company] <> null), {"Company", "Name"}), {"Name"}, "search", JoinKind.LeftOuter),
#"Expanded search" = Table.ExpandTableColumn(#"Merged Queries", "search", {"Company"}, {"Newcompany"})
in  #"Expanded search"

enter image description here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.