Forum Discussion

jps_HHH's avatar
jps_HHH
Helper II
2 years ago
Solved

count when column is filled in

I have a table with several dates column to be filled in. 

 

Batch1 dilevery date1 dilevery date3 dilevery date4 dilevery date
A2024.09.02   
B2024.12.022025.04.022025.07.022025.09.02
C2024.10.02   
D2024.03.022024.04.022024.05.02 

 

I would like to create a new column (using tranformation data) to count the number of columns filled in i.e. the number of deliveries. 

For batch A is 1; batch B is 4; batch C is 1; batch D is 3

  • Hi jps_HHH - you can create it using a function List.functon as follows in to get the delivery date columns

    In the Power Query Editor, click on "Add Column" in the ribbon.Select "Custom Column" from the dropdown menu.

     

    List.NonNullCount({[1 dilevery date],[2 dilevery date],[3 dilevery date],[4 dilevery date]})

     

    output:

     

    Hope it works 

     

     

     

2 Replies

  • Hi jps_HHH - you can create it using a function List.functon as follows in to get the delivery date columns

    In the Power Query Editor, click on "Add Column" in the ribbon.Select "Custom Column" from the dropdown menu.

     

    List.NonNullCount({[1 dilevery date],[2 dilevery date],[3 dilevery date],[4 dilevery date]})

     

    output:

     

    Hope it works 

     

     

     

  • Are there always 4 date columns?

    If so something like this should do the trick:
    = Table.AddColumn(#"Changed Type1", "Count", each List.NonNullCount({[1 dilevery date_1], [3 dilevery date], [4 dilevery date]}), Int64.Type)