0

I need to add a column to a nested table with values based on a condition. Each field in the new column "Hybrid Value" should get the value of field "AlutMufchetetColumn", if the value of ID equals "Meyuadot"

This is the code, I think I still can't get my head around the passed on variables and scopes.

This is the nested table located in column "CSV Table With ID and Kvutsa"

You can see the numbers under Hybrid Value, which are taken from Column Alutmufchetet, only when the values of ID include the string "AlutMuf"

ShoviHibrid=

      let
         X= Table.FromRecords(Table.TransformRows(IDandKvutsa, (r)=>

         Record.TransformFields(r, {"CSV Table With ID and Kvutsa", 
         (TableField)=>

        Table.AddColumn([CSV Table With ID and Kvutsa],{"Hybrid Value",              

              if Text.Contains(TableField[ID],"Meyuadot" ) then

                        "Success" else "not success"  })

               })))

     in

         X
4
  • @horseyride see my edited post. Let me know if I need to provide more details. Commented Aug 20, 2024 at 20:42
  • I edited the code too, to remove unnecessary steps. I will add them later. Commented Aug 20, 2024 at 21:07
  • IDandKvutsa is the main table. In column "CSV Table With ID and Kvutsa" I have the nested tables. What I'm trying to do, is transforming the fields in "CSV Table With ID and Kvutsa" to add columns to the nested table. Commented Aug 21, 2024 at 5:03
  • The table above is the nested one. The first half of the code deals with fetching the filed with the table, the second half adds a column to the nested table. I think I miss something about records transformation and passing variable through the functions Commented Aug 21, 2024 at 14:40

1 Answer 1

0

I figured it out, my main mistake (among others) was the {} in the AddColumn function. This is how it should look like:

   ShoviHibrid=

      let
         X= Table.FromRecords(Table.TransformRows(IDandKvutsa, (r)=>

         Record.TransformFields(r, {"CSV Table With ID and Kvutsa", 
         (TableField)=>

        Table.AddColumn(TableField,"Hybrid Value", (SubRecord)=>             

              if Text.Contains(SubRecord[ID],"Meyuadot") then

                        "Success" else "not success"

              )})))

     in

         X
Sign up to request clarification or add additional context in comments.

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.