Forum Discussion

SebSchoon1's avatar
SebSchoon1
Icon for Post Patron rankPost Patron
3 years ago
Solved

List of columns in Table.Addcolumn IF Then else

Hello fellows, I need a god like master to solve this

 

I have a Table into this step

 

#"Table Source" 

 

In this table i have some columns which contains "%" in the cells.

 

I Need to verify This for specific columns which can be changing over Time  But these are always Staring By "Column"

 

I have created a list to solve this 

 

= Table.ToList(Table.SelectRows(#"Converti en table", each Text.Contains([Column1], "Column")))

 

 

I would like to add a conditionnal column which check for each column name if they contains "%" in the Values.

 

So instead of [Column7] and [Column9] in this formula

 

= Table.AddColumn(#"Table Source", "Personnalisé", each if Text.Contains([Column7], "%") or Text.Contains([Column9], "%") then "A" else null)

 

I woul like something Like 

 

= Table.AddColumn(#"Table Source", "Personnalisé", each if Text.Contains("List of columns to Check", "%") then "A" else null)

 

 

 

Is this feasible?

 

Many thanks !

  • SebSchoon1's avatar
    SebSchoon1
    3 years ago

    Hello,  I have changed the approach by unpivoting columns,

     

    Ad conditional columns 

     

    if (Text.contains, %) column [Valeur] and Column Attribute Text.StartsWith (Column) Then "RemiseDiscount"

     

    then group by item 

     

    add index column

    conditional column => If Attributes = "Code article" then [Index]

    Fill down

    Group

    Remove index volumn

    Promote headers in nested tables

    Table.combine

    Unpivot columns

    Conditional to check if a value in column [Attributes] contains Column AND column [Values] Contains sign  €  if yes then Price HT

     

    Then group

    index

    conditional check

    fill down 

    group

    table.combine

    That's it

     

    🙂

3 Replies

  • wdx223_Daniel's avatar
    wdx223_Daniel
    Icon for Community Champion rankCommunity Champion

    if List.Contains({List of columns to check},"%",(x,y)=>Text.Contains(x,y)) then "A" else null

    • SebSchoon1's avatar
      SebSchoon1
      Icon for Post Patron rankPost Patron

      It does not work , 

       

      Any chance to change the approach, and Merge any column from #"Table Source"  if in the list of columns representedby #"Personnalisé5"  which refers to columns i want to check in #"Table Source" We find the "%"

       

      If yes, Then merge ?

    • SebSchoon1's avatar
      SebSchoon1
      Icon for Post Patron rankPost Patron

      Hello,  I have changed the approach by unpivoting columns,

       

      Ad conditional columns 

       

      if (Text.contains, %) column [Valeur] and Column Attribute Text.StartsWith (Column) Then "RemiseDiscount"

       

      then group by item 

       

      add index column

      conditional column => If Attributes = "Code article" then [Index]

      Fill down

      Group

      Remove index volumn

      Promote headers in nested tables

      Table.combine

      Unpivot columns

      Conditional to check if a value in column [Attributes] contains Column AND column [Values] Contains sign  €  if yes then Price HT

       

      Then group

      index

      conditional check

      fill down 

      group

      table.combine

      That's it

       

      🙂