• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

My Online Training Hub

Learn Dashboards, Excel, Power BI, Power Query, Power Pivot

  • Courses
  • Pricing
    • Free Courses
    • Power BI Course
    • Excel Power Query Course
    • Power Pivot and DAX Course
    • Excel Dashboard Course
    • Excel PivotTable Course – Quick Start
    • Advanced Excel Formulas Course
    • Excel Expert Advanced Excel Training
    • Excel Tables Course
    • Excel, Word, Outlook
    • Financial Modelling Course
    • Excel PivotTable Course
    • Excel for Customer Service Professionals
    • Excel for Operations Management Course
    • Excel for Decision Making Under Uncertainty Course
    • Excel for Finance Course
    • Excel Analysis ToolPak Course
    • Multi-User Pricing
  • Resources
    • Free Downloads
    • Excel Functions Explained
    • Excel Formulas
    • Excel Add-ins
    • IF Function
      • Excel IF Statement Explained
      • Excel IF AND OR Functions
      • IF Formula Builder
    • Time & Dates in Excel
      • Excel Date & Time
      • Calculating Time in Excel
      • Excel Time Calculation Tricks
      • Excel Date and Time Formatting
    • Excel Keyboard Shortcuts
    • Excel Custom Number Format Guide
    • Pivot Tables Guide
    • VLOOKUP Guide
    • ALT Codes
    • Excel VBA & Macros
    • Excel User Forms
    • VBA String Functions
  • Members
    • Login
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member
  • Login

Loading / identifing a ranges of rows |Power Query|Excel Forum|My Online Training Hub

You are here: Home / Loading / identifing a ranges of rows |Power Query|Excel Forum|My Online Training Hub
Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search|Last Search Results
Search
Forum Scope




Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Search Search
sp_RankInfo
Lost password?
sp_CrumbsHome HomeExcel ForumPower QueryLoading / identifing a ranges of r…
sp_PrintTopic sp_TopicIcon
Loading / identifing a ranges of rows
Avatar
Mark Mahoney

New Member
Members
Level 0
Forum Posts: 1
Member Since:
April 30, 2021
sp_UserOfflineSmall Offline
1
April 30, 2021 - 4:54 am
sp_Permalink sp_Print

I have data that I want to ensure that specific ranges of rows remain in the dataset.

In the example below. I want to keep 4 rows below item c in col1. For every entry of 'c'.

Col 3 shows for example purposes the rows that I want to remain.

I cannot for the life of me find a way of doing it.

Col 1 Col 2 Col 3
a 1  
b 2  
c 3 x
x 4 x
y 5 x
fff 6 x
g 7  
h 8  
i 9  
j 10  
k 11  
l 12  
c 13 x
d 14 x
e 15 x
f 16 x
g 17  
r 18  
s 19  
c 20 x
cd 21 x
er 22 x
ff 23 x
Avatar
Mynda Treacy
Admin
Level 10
Forum Posts: 4619
Member Since:
July 16, 2010
sp_UserOfflineSmall Offline
2
April 30, 2021 - 7:19 pm
sp_Permalink sp_Print

Hi Mark,

Welcome to our forum!

You can use this formula in a new column to extract the values from column 1:

= try if [Col 1] = "c" then [Col 1] else
if #"Changed Type"{[Col 2]-2} [Col 1] = "c" then #"Changed Type"{[Col 2]-1} [#"Col 1"] else 
if #"Changed Type"{[Col 2]-3} [Col 1] = "c" then #"Changed Type"{[Col 2]-1} [#"Col 1"] else 
if #"Changed Type"{[Col 2]-4} [Col 1] = "c" then #"Changed Type"{[Col 2]-1} [#"Col 1"] else null otherwise null

 

Then filter out the null rows. See file attached.

Mynda

Avatar
SunnyKow
Puchong, Malaysia

VIP
Members


Trusted Members
Level 8
Forum Posts: 1432
Member Since:
June 25, 2016
sp_UserOfflineSmall Offline
3
April 30, 2021 - 10:19 pm
sp_Permalink sp_Print

Hi Mark

You could also use a formula instead.

In cell C2 enter =IF(A2="c",1,IF(C1<>0,IF(C1<>4,C1+1,0),0))

You can then filter out the zeros.

Sunny

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Philip Treacy, Peter Venkatrao, QSolutions Group
Guest(s) 8
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 880
Purfleet: 414
Frans Visser: 346
David_Ng: 306
lea cohen: 237
Jessica Stewart: 219
A.Maurizio: 213
Aye Mu: 201
Hans Hallebeek: 185
Newest Members:
Kate Dyka
Kwaje Alfred Mogga
thong nguyen
Appiagyei Kofi Frimpong
Hilary Burchfield
Richie Wright
Adel Kock
Barbara Murray
Doug Milne
Siobhan Stringer
Forum Stats:
Groups: 3
Forums: 24
Topics: 6546
Posts: 28655

 

Member Stats:
Guest Posters: 49
Members: 32832
Moderators: 2
Admins: 4
Administrators: Mynda Treacy, Philip Treacy, Catalin Bombea, FT
Moderators: Velouria, Riny van Eekelen
© Simple:Press —sp_Information

Sidebar

Blog Categories

  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • Excel Office Scripts
  • Excel PivotTables
  • Excel Shortcuts
  • Excel VBA
  • General Tips
  • Online Training
  • Outlook
  • Power Apps
  • Power Automate
  • Power BI
  • Power Pivot
  • Power Query
microsoft mvp logo
trustpilot excellent rating
Secured by Sucuri Badge
MyOnlineTrainingHub on YouTube Mynda Treacy on Linked In Mynda Treacy on Instagram Mynda Treacy on Twitter Mynda Treacy on Pinterest MyOnlineTrainingHub on Facebook

Sign up to our newsletter and join over 400,000
others who learn Excel and Power BI with us.

 

Company

  • About My Online Training Hub
  • Disclosure Statement
  • Frequently Asked Questions
  • Guarantee
  • Privacy Policy
  • Terms & Conditions
  • Testimonials
  • Become an Affiliate
  • Sponsor Our Newsletter

Support

  • Contact
  • Forum
  • Helpdesk - For Technical Issues

Copyright © 2023 · My Online Training Hub · All Rights Reserved. Microsoft and the Microsoft Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. Product names, logos, brands, and other trademarks featured or referred to within this website are the property of their respective trademark holders.