ADVERTISEMENT
  • About
  • Advertise
  • Privacy & Policy
  • Contact
Office Learner
ADVERTISEMENT
  • Home
  • Excel
  • Word
  • PowerPoint
  • Outlook
  • Microsoft Copilot
  • Power BI
  • Microsoft 365
  • Microsoft Teams
  • OneNote
No Result
View All Result
  • Home
  • Excel
  • Word
  • PowerPoint
  • Outlook
  • Microsoft Copilot
  • Power BI
  • Microsoft 365
  • Microsoft Teams
  • OneNote
No Result
View All Result
Office Learner
No Result
View All Result
Home Power BI

Count Rows Before and After a Power Query Filter

Tanjila Rashid by Tanjila Rashid
December 4, 2026
in Power BI
0
Count Rows Before and After a Power Query Filter
0
SHARES
0
VIEWS
Share on FacebookShare on Twitter

Count Rows Before and After a Power Query Filter

Use Table.RowCount on the original table and again on the filtered table to measure exactly how many records a Power Query filter removes. In this practice query, five workshop requests include three marked Ready and two marked Hold. The unfiltered count should be 5 and the filtered count should be 3. Keeping both values together makes a missing or unexpectedly strict filter easier to diagnose when the query changes.

ADVERTISEMENT

Build the sample in a blank query

Open Power BI Desktop with a new practice file. Enter the Power Query editor using Transform data. Create a blank query, select it in the Queries pane, and open Advanced Editor. Replace the blank query’s script with the following five lines. If you paste one line at a time, keep the trailing commas on the first two assignment lines. Preserve the straight quotation marks around status values. A complete let expression can also be pasted on one line if your editor has flattened the displayed text.

let

Source = #table(type table [Ticket = text, Status = text], {{"W01","Ready"},{"W02","Hold"},{"W03","Ready"},{"W04","Hold"},{"W05","Ready"}}),

ReadyRows = Table.SelectRows(Source, each [Status] = "Ready"),

Counts = #table(type table [Stage = text, Rows = number], {{"Before filter",Table.RowCount(Source)},{"After filter",Table.RowCount(ReadyRows)}})

in Counts

After you accept the script, select the Counts step. The preview should have two rows with the stage labels Before filter and After filter. Read the Rows column for the values 5 and 3. This output table has two records of its own. Those two output records describe the counts of the input tables. If you run Table.RowCount on Counts itself, you get 2 regardless of how many rows survived the filter.

Verify both counts against the table

Select the Source step and check that it shows one ticket per row. W01, W03, and W05 have Ready in the Status column. W02 and W04 have Hold. Select ReadyRows next and confirm that only the three Ready tickets appear. Returning to the stage count closes the check. In code, Table.SelectRows supplies the filtered table and Table.RowCount supplies a number. The count applies to the exact step you give it, so choosing a step earlier or later in a real query can change the answer.

Try changing W03 from Ready to Hold in Advanced Editor. The original count stays at 5, while After filter falls to 2. Change W03 back, then add a new input record for W06 with a Ready status. The counts should become 6 and 4. Those checks distinguish two things that can otherwise look alike when a report total changes. A change to a status can alter how many records pass the filter. A new input record increases the original count and may change the filtered count as well.

Diagnose an unexpected count

A zero after the filter is a valid result. If you expected some matches, inspect the actual Status values at Source. A vendor export might use ready, Ready followed by a space, or a longer phrase such as Ready for review. The exercise compares the field to an exact text value. Decide which variants should qualify before you normalize the input. If the meanings differ, count them separately or correct them at the source rather than allowing them all through by accident.

Duplicates are another common source of confusion. Table.RowCount counts records, so two rows that share a Ticket value each contribute one to the total. If your reporting question is how many unique tickets are present, make uniqueness an explicit step before counting. Inspect repeated ticket numbers first. A ticket might have several legitimate status updates, and collapsing those records without a rule could hide a recent change.

If both counts are unexpectedly identical, confirm that the second Table.RowCount receives ReadyRows. A copied expression that still calls Table.RowCount(Source) is syntactically valid and will report an apparently reassuring match. Set all five sample statuses to Hold and see if After filter reaches zero. That small control case is useful when the difference between the real counts is usually small or sometimes zero on purpose.

Adapt the check to a production query

The example ends with in Counts so the result is a two-row summary. If your original query must keep outputting detailed records for a report, leave its final expression intact. Build a separate diagnostic query or make a practice copy before adding a counts table. Microsoft documents that separately evaluated references can cause additional source retrieval in some workloads. Check refresh behavior before adding several independent counts to a large connected model.

The exercise uses Power BI Desktop and M syntax. In another Power Query host, or in the newer editor interface, the blank-query and Advanced Editor controls may be placed differently. Verify the selected query before pasting. For a final exercise, add a sixth row with an empty text status and then replace that empty text with Ready. Predict Before filter and After filter both times. Before filter should stay at 6, with After filter changing from 3 to 4. That makes a useful check on which step the formula is counting.

If you keep a copy of the counts for weekly review, write down the date, source export, and filter value next to each pair of totals. A result of three Ready tickets on Monday is comparable with Friday's result only if both exports cover the same kind of records. When the filter intentionally changes, run the old and new conditions against the same input once. That makes it possible to distinguish a change in the definition of Ready from a change in the underlying requests.

Sources and related reading

Microsoft Learn Table.RowCount

Microsoft Learn Table.SelectRows

Microsoft Learn #table constructor

Microsoft guidance on query references

Classify a variance direction with Number Sign in Power Query

Tags: Power BIPower Query count rows before and after filter
ADVERTISEMENT
Previous Post

Rename Overlapping PowerPoint Objects in the Selection Pane

Next Post

Flag an Outlook Web Email and Find It After New Mail Arrives

Tanjila Rashid

Tanjila Rashid

Next Post
Flag an Outlook Web Email and Find It After New Mail Arrives

Flag an Outlook Web Email and Find It After New Mail Arrives

ADVERTISEMENT
  • Trending
  • Comments
  • Latest
10 Microsoft 365 Copilot Features That Transform Word and Outlook in 2025

8 Hidden Excel Features That Power Users Swear By (2026 Edition)

October 8, 2026
PowerPoint Morph Transition Masterclass: Create Cinematic Animations in 2026

PowerPoint Morph Transition Masterclass: Create Cinematic Animations in 2026

October 8, 2026
Excel GROUPBY & PIVOTBY: The New Array Functions That Replace PivotTables

Excel GROUPBY & PIVOTBY: The New Array Functions That Replace PivotTables

October 8, 2026
Excel PIVOTBY Function in 2026: The Ultimate Guide to Dynamic Pivot Analysis Without Pivot Tables

Excel PIVOTBY Function in 2026: The Ultimate Guide to Dynamic Pivot Analysis Without Pivot Tables

October 8, 2026
Spreadsheet Layout

What is spreadsheet? and how it works!

0
Spreadsheet Layout

Spreadsheet Layout

0
Spreadsheet Layout

IF function of Google Sheets – usage and formula examples

0

5 Google Sheets tricks that you always need!

0
Flag an Outlook Web Email and Find It After New Mail Arrives

Flag an Outlook Web Email and Find It After New Mail Arrives

December 4, 2026
Count Rows Before and After a Power Query Filter

Count Rows Before and After a Power Query Filter

December 4, 2026
Rename Overlapping PowerPoint Objects in the Selection Pane

Rename Overlapping PowerPoint Objects in the Selection Pane

December 4, 2026
Show Bookmark Boundaries in Word Before Editing

Show Bookmark Boundaries in Word Before Editing

December 4, 2026

Recent News

Flag an Outlook Web Email and Find It After New Mail Arrives

Flag an Outlook Web Email and Find It After New Mail Arrives

December 4, 2026
Count Rows Before and After a Power Query Filter

Count Rows Before and After a Power Query Filter

December 4, 2026
Rename Overlapping PowerPoint Objects in the Selection Pane

Rename Overlapping PowerPoint Objects in the Selection Pane

December 4, 2026
Show Bookmark Boundaries in Word Before Editing

Show Bookmark Boundaries in Word Before Editing

December 4, 2026
Office Learner

OfficeLearner is a place where you can learn PowerPoint, Excel, Word Data Analysis, and other Office related programs. We provide tips, how to guide and also provide Excel solutions to your business problems

Follow Us

DMCA.com Protection Status

Browse by Category

  • Clipchamp
  • Excel
  • Google Sheets
  • Loop
  • Microsoft 365
  • Microsoft Copilot
  • Microsoft Designer
  • Microsoft Forms
  • Microsoft Loop
  • Microsoft Sway
  • Microsoft Teams
  • Microsoft Viva
  • Microsoft Whiteboard
  • OneDrive
  • OneNote
  • Outlook
  • Planner
  • Power Apps
  • Power Automate
  • Power BI
  • PowerPoint
  • SharePoint
  • Teams
  • Visio
  • Word

Recent News

Flag an Outlook Web Email and Find It After New Mail Arrives

Flag an Outlook Web Email and Find It After New Mail Arrives

December 4, 2026
Count Rows Before and After a Power Query Filter

Count Rows Before and After a Power Query Filter

December 4, 2026
  • About
  • Advertise
  • Privacy & Policy
  • Contact

© 2022 OfficeLearner - Free Excel, PowerPoint & Word Tutorial & Online Courses

No Result
View All Result

© 2022 OfficeLearner - Free Excel, PowerPoint & Word Tutorial & Online Courses

This website uses cookies. By continuing to use this website you are giving consent to cookies being used. Visit our Privacy and Cookie Policy.