# Tags
**Software** : [[02 - Tags/Software/Power Query]]
**Functions** used : [[Excel.CurrentWorkbook]] [[Table.TransformColumnTypes]] [[Table.Sort]] [[Table.Group]] [[Table.SelectRows]] [[Table.ExpandTableColumn]] [[Table.SelectColumns]]
**Date** : 29-March-2025
# Description
Ever wondered how to seamlessly extract a sequence of numbers from a table, especially when analyzing your stock portfolio? 📈 Dive into this tutorial as we unravel the magic of Power Query in Excel to make your stock analysis smoother and more efficient! 🧙♂️💼 🔍 What we'll cover: Basics of Power Query and its interface 🖥️ Steps to extract consecutive numbers from a table 📑➡️🔢 Real-life application: Enhancing stock portfolio analysis 🌐💰 Don't forget to 👍 like, 💬 comment, and 🔔 subscribe for more tutorials that empower your data journey! 🌟 Happy querying! 🎉
# Video Link
<iframe width="560" height="315" src="https://www.youtube.com/embed/NuOb7pKj2_U?si=xscYKWZ4BI0AaBiF" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
[GITHUB File Link](https://github.com/jbotes/powerbiTutorials/blob/main/PQ_Consecutivenumbers_Video2.xlsx)
# M-Query
```mquery
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Stock", type text}, {"Shares", Int64.Type}, {"Value", Int64.Type}, {"Holding Date", type date}}),
#"Sorted Rows" = Table.Sort(#"Changed Type",{{"Stock", Order.Ascending},{"Holding Date", Order.Ascending}}),
#"Grouped Rows" = Table.Group(#"Sorted Rows", {"Stock", "Shares"}, {{"Count", each Table.RowCount(_), Int64.Type}, {"records", each _, type table [Stock=nullable text, Shares=nullable number, Value=nullable number, Holding Date=nullable date]}}, GroupKind.Local),
#"Filtered Rows" = Table.SelectRows(#"Grouped Rows", each [Count] > threshold),
#"Expanded records" = Table.ExpandTableColumn(#"Filtered Rows", "records", {"Stock", "Shares", "Value", "Holding Date"}, {"Stock.1", "Shares.1", "Value", "Holding Date"}),
#"Removed Other Columns" = Table.SelectColumns(#"Expanded records",{"Stock.1", "Shares.1", "Value", "Holding Date"})
in
#"Removed Other Columns"
```
```mquery
let
Source = Excel.CurrentWorkbook(){[Name="threshold"]}[Content],
Custom1 = Source{0}[Column1]
in
Custom1
```
## Optional Tags
**Tags** :
**Technique** : [[Input Parameter]]