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
JBDelvaux
Helper I
Helper I

Replace "0" value with another one if available

Greetings, I have a table as such. These informations are received to the database but from different devices that do not have access ot the same informations. As a result, one of the device cannot accurately tell which user did the job, leaving it to a UserId of 0.

JBDelvaux_0-1704200912116.png

I would like, if a line with a userID value is at "0" to check if another line with the same "Piece" number exist with a value different than 0 and to replace said 0 with the UserID found. If no other number is found, to keep it at 0.

1 ACCEPTED SOLUTION
m_dekorte
Super User
Super User

You can try something like this. Note I'm using a simple example.

Do "Group By" on the Piece column, Choose "All Rows" and transform the result, like so.

 

let
  Source = Table.FromColumns(
    {
      {"A" .. "H"}, 
      {123 .. 127, 0, 0, 128}, 
      {546038 .. 546042, 546042, 546042, 546043}
    }, 
      {"Column1", "UserId", "Piece"}
  ), 
  GroupRows = Table.Group(
    Source, 
    {"Piece"}, 
    {{"t", each Table.TransformColumns(_, {"UserId", (x) => List.Max(_[UserId])})}}
  ), 
  ExpandAll = Table.Combine(GroupRows[t])
in
  ExpandAll

 

I hope this is helpful

View solution in original post

1 REPLY 1
m_dekorte
Super User
Super User

You can try something like this. Note I'm using a simple example.

Do "Group By" on the Piece column, Choose "All Rows" and transform the result, like so.

 

let
  Source = Table.FromColumns(
    {
      {"A" .. "H"}, 
      {123 .. 127, 0, 0, 128}, 
      {546038 .. 546042, 546042, 546042, 546043}
    }, 
      {"Column1", "UserId", "Piece"}
  ), 
  GroupRows = Table.Group(
    Source, 
    {"Piece"}, 
    {{"t", each Table.TransformColumns(_, {"UserId", (x) => List.Max(_[UserId])})}}
  ), 
  ExpandAll = Table.Combine(GroupRows[t])
in
  ExpandAll

 

I hope this is helpful

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.