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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
joshua1990
Post Prodigy
Post Prodigy

Change blank by earliest text value per week

Hi all!

I have an archive with the weekly extract of our sales data in a table like this:

Archival Year-Week Order Year-Week Value
2023-01 1 2023-01 5
2023-01 2 null 6

 

As you can see, it happens the is a "null" in the Year-Week column.

I would like to change the null to the earliest Year-Week, that is available within the same Archival Year-Week value.

 

How would you do that within PQ if the table has rows more than 50MM?

 

1 ACCEPTED SOLUTION
v-cgao-msft
Community Support
Community Support

Hi @joshua1990 ,

Hope it helps.

let
  Source = Table.FromRows(
    Json.Document(
      Binary.Decompress(
        Binary.FromText("i45WMjIwMtY1MFTSUQJhBM9UKVYHWdYIiPNKc3KAlJlSbCwA", BinaryEncoding.Base64), 
        Compression.Deflate
      )
    ), 
    let
      _t = ((type nullable text) meta [Serialized.Text = true])
    in
      type table [#"Archival Year-Week" = _t, Order = _t, #"Year-Week" = _t, Value = _t]
  ), 
  #"Changed Type" = Table.TransformColumnTypes(
    Source, 
    {
      {"Archival Year-Week", type date}, 
      {"Order", Int64.Type}, 
      {"Year-Week", type date}, 
      {"Value", Int64.Type}
    }
  ), 
  Custom1 = Table.TransformColumns(
    #"Changed Type", 
    {
      "Year-Week", 
      each 
        if _ <> null then
          _
        else
          Table.Group(
            #"Changed Type", 
            {"Archival Year-Week"}, 
            {{"Min", each List.Min([#"Archival Year-Week"])}}
          )[Min]{0}
    }
  )
in
  Custom1

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

View solution in original post

2 REPLIES 2
v-cgao-msft
Community Support
Community Support

Hi @joshua1990 ,

Hope it helps.

let
  Source = Table.FromRows(
    Json.Document(
      Binary.Decompress(
        Binary.FromText("i45WMjIwMtY1MFTSUQJhBM9UKVYHWdYIiPNKc3KAlJlSbCwA", BinaryEncoding.Base64), 
        Compression.Deflate
      )
    ), 
    let
      _t = ((type nullable text) meta [Serialized.Text = true])
    in
      type table [#"Archival Year-Week" = _t, Order = _t, #"Year-Week" = _t, Value = _t]
  ), 
  #"Changed Type" = Table.TransformColumnTypes(
    Source, 
    {
      {"Archival Year-Week", type date}, 
      {"Order", Int64.Type}, 
      {"Year-Week", type date}, 
      {"Value", Int64.Type}
    }
  ), 
  Custom1 = Table.TransformColumns(
    #"Changed Type", 
    {
      "Year-Week", 
      each 
        if _ <> null then
          _
        else
          Table.Group(
            #"Changed Type", 
            {"Archival Year-Week"}, 
            {{"Min", each List.Min([#"Archival Year-Week"])}}
          )[Min]{0}
    }
  )
in
  Custom1

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

ronrsnfld
Super User
Super User

If your actual data is similar to what you show, simply select that column and Fill Down.

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

PBI_Carousel_NL_June

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

Top Solution Authors
Top Kudoed Authors