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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Andresgamez28
New Member

How to remove Null values from a column without affecting the entire row

Hello,

I have the next table with null values, how can I move the values to only one row without affecting the data?

 

Table to fix:

 

Andresgamez28_0-1724200921320.png

 

What I need to get as a result:

Andresgamez28_1-1724200933810.png

 

 

Thank you.

3 ACCEPTED SOLUTIONS
AlienSx
Super User
Super User

let
    Source = your_table,
    func = (tbl) => 
        [cols = Table.ToColumns(tbl), 
        to_table = Table.FromColumns(
            List.FirstN(cols, 3) & 
            List.Transform(
                List.RemoveFirstN(cols, 3),
                (x) => List.Skip(x, (w) => w is null)
            ),
            Table.ColumnNames(tbl)
        )][to_table],
    group = Table.Group(Source, {"Day", "Date", "Operator"}, {{"x", func}}),
    result = Table.Combine(group[x])
in
    result

View solution in original post

dufoq3
Super User
Super User

Hi @Andresgamez28, similar approach here:

 

Output

dufoq3_1-1724252111265.png

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtQ3sNA3MjAyUdJRck4sygFSxmZmRuZAGopidbCqAiIzKwMDIFJw9CWoFEl1gC9BpUBkaKhnClZkhN2BFqgOxKIKlwOxK8XqQJxK4Q6MBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, Operator = _t, #"Docket No" = _t, #"Start Time" = _t, #"Finish Time" = _t, Hours = _t]),
    // You can delete this step when applying on real data.
    RepalceBlankToNull = Table.TransformColumns(Source, {}, each if _ = "" then null else _),
    GroupedRows = Table.Group(RepalceBlankToNull, {"Date", "Operator"}, {{"All", each Table.FromColumns(List.Transform(Table.ToColumns(_), each List.FirstN(List.RemoveNulls(_), 1)), Value.Type(_)), type table}}),
    Combined = Table.Combine(GroupedRows[All])
in
    Combined

 


Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

View solution in original post

Omid_Motamedise
Super User
Super User

You can use this formula (Source is your data )

let
Source = Excel.CurrentWorkbook(){[Name="Table3"]}[Content],

List={"Day", "Date", "Operator"},
Unpivoted = Table.UnpivotOtherColumns(Source, List, "Attribute", "Value"),
Pivoted = Table.Pivot(Unpivoted, List.Distinct(Unpivoted[Attribute]), "Attribute", "Value", List.First),
Custom1 = Table.Sort( Pivoted & Table.Repeat(Table.SelectColumns(Pivoted,List),4), "Date")
in
Custom1

If my answer helped solve your issue, please consider marking it as the accepted solution. It helps others in the community find answers faster—and keeps the community growing stronger!
You can also check out my YouTube channel for tutorials, tips, and real-world solutions in Power Query with the following link
https://youtube.com/@omidbi?si=96Bo-ZsSwOx0Z36h

View solution in original post

5 REPLIES 5
Omid_Motamedise
Super User
Super User

You can use this formula (Source is your data )

let
Source = Excel.CurrentWorkbook(){[Name="Table3"]}[Content],

List={"Day", "Date", "Operator"},
Unpivoted = Table.UnpivotOtherColumns(Source, List, "Attribute", "Value"),
Pivoted = Table.Pivot(Unpivoted, List.Distinct(Unpivoted[Attribute]), "Attribute", "Value", List.First),
Custom1 = Table.Sort( Pivoted & Table.Repeat(Table.SelectColumns(Pivoted,List),4), "Date")
in
Custom1

If my answer helped solve your issue, please consider marking it as the accepted solution. It helps others in the community find answers faster—and keeps the community growing stronger!
You can also check out my YouTube channel for tutorials, tips, and real-world solutions in Power Query with the following link
https://youtube.com/@omidbi?si=96Bo-ZsSwOx0Z36h
dufoq3
Super User
Super User

Hi @Andresgamez28, similar approach here:

 

Output

dufoq3_1-1724252111265.png

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtQ3sNA3MjAyUdJRck4sygFSxmZmRuZAGopidbCqAiIzKwMDIFJw9CWoFEl1gC9BpUBkaKhnClZkhN2BFqgOxKIKlwOxK8XqQJxK4Q6MBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, Operator = _t, #"Docket No" = _t, #"Start Time" = _t, #"Finish Time" = _t, Hours = _t]),
    // You can delete this step when applying on real data.
    RepalceBlankToNull = Table.TransformColumns(Source, {}, each if _ = "" then null else _),
    GroupedRows = Table.Group(RepalceBlankToNull, {"Date", "Operator"}, {{"All", each Table.FromColumns(List.Transform(Table.ToColumns(_), each List.FirstN(List.RemoveNulls(_), 1)), Value.Type(_)), type table}}),
    Combined = Table.Combine(GroupedRows[All])
in
    Combined

 


Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

amazing

AlienSx
Super User
Super User

let
    Source = your_table,
    func = (tbl) => 
        [cols = Table.ToColumns(tbl), 
        to_table = Table.FromColumns(
            List.FirstN(cols, 3) & 
            List.Transform(
                List.RemoveFirstN(cols, 3),
                (x) => List.Skip(x, (w) => w is null)
            ),
            Table.ColumnNames(tbl)
        )][to_table],
    group = Table.Group(Source, {"Day", "Date", "Operator"}, {{"x", func}}),
    result = Table.Combine(group[x])
in
    result
lbendlin
Super User
Super User

What should happen when you have more than or less than one value per column ?

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.