# List.RemoveRange

## Syntax of List.RemoveRange Function

The syntax of the List.RemoveRange function is as follows:

List.RemoveRange(list as list, offset as number, count as number) as list

``` The List.RemoveRange function takes three arguments: - list: A list from which items need to be removed. - offset: A number that specifies the starting index of the range. - count: A number that specifies the number of items to remove. How List.RemoveRange Function Works The List.RemoveRange function works by creating a new list that excludes the range of items specified by the offset and count parameters. The function does not modify the original list and returns a new list containing the remaining items. The following example illustrates how the List.RemoveRange function works: ```

let

myList = {1, 2, 3, 4, 5, 6, 7},

myRange = List.RemoveRange(myList, 2, 3)

in

myRange

``` In this example, we have a list of numbers from 1 to 7. We want to remove the range of items starting from index 2 and including the next 3 items. The List.RemoveRange function is used to create a new list that excludes the specified range. The resulting list contains the remaining items, which are 1, 2, and 6. Applications of List.RemoveRange Function The List.RemoveRange function can be used in a variety of scenarios. Some common applications of this function are: 1. Removing Rows from a Table When working with tables, you may need to remove a range of rows. The List.RemoveRange function can be used to achieve this. You can first convert the table to a list using the Table.ToList function, apply the List.RemoveRange function to remove the rows, and then convert the resulting list back to a table using the Table.FromList function. 2. Removing Items from a List In some cases, you may need to remove a range of items from a list. The List.RemoveRange function can be used to achieve this. You can specify the range of items to be removed using the offset and count parameters. 3. Trimming Data in Text Columns When working with text columns, you may need to remove a range of characters from the beginning or end of the text. The List.RemoveRange function can be used to achieve this. You can convert the text column to a list of characters using the Text.ToCharacters function and then apply the List.RemoveRange function to remove the unwanted characters. In conclusion, the List.RemoveRange function is a powerful tool in Power Query that can be used to remove a range of items from a list. This function can be applied to a variety of scenarios, such as removing rows from a table, removing items from a list, and trimming data in text columns. By understanding the syntax and applications of this function, you can improve the efficiency of your data transformation tasks in Power Query. Power Query and M Training Courses by G Com Solutions (0800 998 9248) Power Query and M Intensive Training Course £1,260.00 – £31,860.00 Select optionsContinue Loading Done Power Query and M Introduction £474.00 – £11,700.00 Select optionsContinue Loading Done Power Query and M Intermediate £474.00 – £11,700.00 Select optionsContinue Loading Done Power Query and M Advanced £474.00 – £11,700.00 Select optionsContinue Loading Done Upcoming Courses Contact Us Subject Your Name (required) Company/Organisation Email (required) Telephone Training Course(s) Power BI Intensive TrainingPower BI introduction Power BI IntermediatePower BI AdvancedDAXPower Query MPower BI CertificationPower BI AdministrationPower PlatformPower AutomatePower AppsOTHER Your Message Upload Example Document(s) (Zip multiple files) ```
``` ```
``` ```
``` ```
``` ```
``` ```