Forum Discussion

tgjones43's avatar
tgjones43
Icon for Helper IV rankHelper IV
4 years ago
Solved

How to ignore a column when counting in Power Query

Hi all

 

I have a table of >1000 rows, with each row looking like this:

 

IndexSpot 1Spot 2Spot 3Spot 4Spot 5Spot 6Spot 7Spot 8Spot 9Spot 10Spot 11TICKNO TICK
1TICKTICKTICKTICKTICKTICKTICKTICKTICKTICKTICK110
2NO TICKNO TICKNO TICKNO TICKNO TICKNO TICKNO TICKNO TICKNO TICKNO TICKNO TICK011

 

Where the last 2 columns add the number of TICK and NO TICK values for each row using this code (for NO TICK):

 

= Table.AddColumn(#"Replaced Value #2.1", "NO TICK", each List.Count(
List.Select(
Text.Split(
Text.Combine(
List.Transform(Record.ToList(_),each Text.From(_))
,",")
,
","
),each _ ="NO TICK")
))

 

but what I'd like to do is ignore whatever is in the column Spot 11, so in the example above the figures would be 10 not 11 in the last 2 columns.

 

What is the easiest way to do this?

 

Thank you!

3 Replies

    • tgjones43's avatar
      tgjones43
      Icon for Helper IV rankHelper IV

      Thanks amitchandak do you know how to fit that command into the code that I pasted? I can't work this out.

      • tgjones43's avatar
        tgjones43
        Icon for Helper IV rankHelper IV

        I figured it out, pasting the code below in case it is useful to anyone else:

         

        = Table.AddColumn(#"Replaced Value #2.1", "NO TICK", each List.Count(
        List.Select(
        Text.Split(
        Text.Combine(
        List.Transform(List.RemoveLastN(Record.ToList(_),1),each Text.From(_))
        ,",")
        ,
        ","
        ),each _ ="NO TICK")
        ))