Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
tgjones43
Helper IV
Helper IV

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!

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

3 REPLIES 3
amitchandak
Super User
Super User

@tgjones43 , You can use List.RemoveLastN and remove last element of the list

https://docs.microsoft.com/en-us/powerquery-m/list-removelastn

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

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")
))

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.