CALCULATETABLE vs FILTER in Power BI DAX
CALCULATETABLE returns a table in a new filter context, the way CALCULATE returns a number. FILTER walks a table and keeps rows that pass a test — usually a measure test on a short list, not every fact row.
Friends! Both functions “filter”, so students use them as synonyms. Why? The names sound like the Filters pane. How? We separate scalar from table on fictional FreshBasket sales, then we count cities whose sales measure clears a bar. One job each.
मित्रांनो! दोन्ही functions नावाने “filter” वाटतात, म्हणून विद्यार्थी त्यांना एकच समजतात. का? नावे Filters pane सारखी आहेत. कसे? FreshBasket च्या sales वर संख्या आणि table वेगळे करायचे, मग मोजायचे किती शहरांचा sales measure पट्टी ओलांडतो. प्रत्येकाचे काम वेगळे.
मित्रों! दोनों functions नाम से “filter” लगते हैं, इसलिए विद्यार्थी उन्हें एक ही मान लेते हैं. क्यों? नाम Filters pane जैसे हैं. कैसे? FreshBasket की sales पर संख्या और table अलग करो, फिर गिनो कितने शहरों का sales measure पट्टी पार करता है. हर एक का काम अलग.
Quick answer
Vertical decision:
- Need a number under a new filter →
CALCULATE. - Need the table under that same style of filter →
CALCULATETABLE. - Need rows where a measure is true →
FILTERonVALUESof a small column. FILTERis not a card by itself. Wrap it inCOUNTROWSorCALCULATE.- Do not
FILTERthe whole Sales table when a column filter is enough. - Test with a year slicer and a city list.
CALCULATETABLE ( Sales, 'Date'[Year] = 2025 )
COUNTROWS ( FILTER ( VALUES ( Customer[City] ), [Total Sales] > 100000 ) )
Why each one, and the rows-in number-out path
Four sales rows:
| Order ID | City | Amount | Year |
|---|---|---|---|
| A | Pune | 100 | 2025 |
| B | Pune | 40 | 2025 |
| C | Nashik | 80 | 2025 |
| D | Pune | 70 | 2024 |
Why CALCULATE when you want a number:
- "Sales in 2025" is one number.
- The year test is a filter. It keeps 2025 rows (100, 40, 80).
SUMwalks those rows. Number out: 220.- You do not need the
FILTERfunction for that.CALCULATE ( [Total Sales], 'Date'[Year] = 2025 )is the column filter.
Why CALCULATETABLE:
- Same filter, but you need the rows themselves, not the sum.
- It returns a table: the three 2025 rows.
- A card cannot show a table. Wrap with
COUNTROWSif the card should say 3, or useCALCULATEif the card should say 220.
Why FILTER:
- "How many cities have sales above 100?" The test is a measure, not a column value on one row.
VALUES ( Customer[City] )is a short list: Pune, Nashik.FILTERkeeps a city only when[Total Sales]for that city clears the bar.COUNTROWSturns the kept list into one number.FILTER ( Sales, Sales[Amount] > 50 )also works, but it walks every fact row. Prefer it only when the test really needs the row. For "year = 2025" or "channel = Online", stay with the column filter.
What to check on the page: change the year slicer. A measure that replaced the year will ignore you. A measure that only counts cities inside the slicer will move.
Real example: 2025 slips, and bills over 500
| Order | City | Amount | Year |
|---|---|---|---|
| A | Mumbai | 500 | 2025 |
| B | Mumbai | 200 | 2025 |
| C | Pune | 100 | 2025 |
| D | Mumbai | 70 | 2024 |
Phone bills for the Mumbai shop: Jan 499, Feb 499, Mar 699. Pune's bill is 399 every month.
Why CALCULATE for a number:
- Question: "2025 sales."
- The year filter keeps A, B and C. The 2024 slip stays out.
- Rows in: three slips.
SUMout: 800. That is a card. NoFILTERfunction required, because Year is a column.
Why CALCULATETABLE:
- Same year filter, but you want the slips themselves (a table), not 800.
- A card still cannot show those rows.
COUNTROWSof that table out: 3.
Why FILTER:
- Question: "how many cities sold more than 300 in the current slicer?"
VALUESof City gives Mumbai and Pune. Mumbai sales 700 in 2025 (500+200). Pune sales 100.FILTERkeeps Mumbai only.COUNTROWSout: 1.- Phone bill question: "how many months is the bill above 500?"
FILTERkeeps March 699. Number out: 1. Jan and Feb stay out. - Do not scan every sales slip with
FILTERjust to say City = Mumbai. The slicer, orCALCULATE ( [Total Sales], City = "Mumbai" ), already does that.
Click Pune. 2025 sales should fall to 100. Cities-above-300 should fall to blank or zero, because 100 is not above 300. If the card still says Mumbai, the formula replaced the slicer instead of working inside it.
What do I need before this guide?
Before and after (look at the tables first)
Before
आधी (Before)
पहले (Before)
After
नंतर (After)
बाद में (After)
Scalar sibling, table sibling
CALCULATE returns a scalar; CALCULATETABLE returns a table in a modified filter context.
CALCULATE एक संख्या परत देतो; CALCULATETABLE बदललेल्या filter context मध्ये एक table परत देतो.
CALCULATE एक संख्या वापस देता है; CALCULATETABLE बदले हुए filter context में एक table वापस देता है.
Sales 2025 =
CALCULATE (
[Total Sales],
'Date'[Year] = 2025
)
That card is a number. The table form is:
Sales Rows 2025 =
CALCULATETABLE (
Sales,
'Date'[Year] = 2025
)
- You can use
CALCULATETABLEas a calculated table in the model when you truly need those rows stored. - Inside a measure, you usually consume it:
COUNTROWSof it, or another function that wants a table. - A card cannot display a table. If the goal is “sales in 2025”, stay with
CALCULATE. - Filter arguments behave like
CALCULATE: they modify filter context.USERELATIONSHIPbelongs in that family too, insideCALCULATEorCALCULATETABLE.
FILTER when the test is a measure
When the test is a measure, FILTER a small list from VALUES, then wrap with COUNTROWS or CALCULATE.
जेव्हा कसोटी measure असेल, तेव्हा VALUES मधली छोटी यादी FILTER करा, मग COUNTROWS किंवा CALCULATE भोवती गुंडाळा.
जब कसौटी measure हो, तब VALUES की छोटी सूची पर FILTER करो, फिर COUNTROWS या CALCULATE से लपेटो.
“How many cities are above 100000?” cannot be a simple column filter. The test is [Total Sales], which is a measure.
Cities Above =
VAR Bar = 100000
RETURN
COUNTROWS (
FILTER (
VALUES ( Customer[City] ),
[Total Sales] > Bar
)
)
Vertical reading:
VALUESbuilds the list of cities in the current context. Keep this list small.FILTERkeeps a city only when its sales measure beats the bar.COUNTROWSturns the surviving table into a number the card can show.- Change the City slicer. The list of candidates changes, so the count should change.
The slow habit
Prefer a column filter inside CALCULATE over FILTER on every fact-table row.
प्रत्येक fact-table row वर FILTER करण्यापेक्षा CALCULATE च्या आत column filter पसंत करा. तो हलका असतो.
हर fact-table row पर FILTER करने से बेहतर है CALCULATE के अंदर column filter. वह हल्का रहता है.
Online Slow =
CALCULATE (
[Total Sales],
FILTER ( Sales, Sales[Channel] = "Online" )
)
- This can be correct and still be a bad habit. It iterates fact rows.
- The lighter shape is
CALCULATE ( [Total Sales], Sales[Channel] = "Online" ). - Reach for
FILTERwhen the condition needs a measure, or logic a boolean column filter cannot say. - If you also need to intersect with a slicer on that same column, that is KEEPFILTERS, not a reason to scan the table.
Ghabru naka — if the measure returns a table error on a card, you forgot to aggregate the table down to a scalar.
Mistakes and calm fixes
| Symptom | Likely cause | Fix |
|---|---|---|
| Card shows an error | Table expression used as a value | CALCULATE or COUNTROWS |
| Count is 1 | FILTER on a single city already sliced |
Clear the slicer or use the right VALUES |
| Slow model | FILTER on Sales |
Column filter inside CALCULATE |
| 2025 ignored | Date column is on Sales, not Date | Filter the Date table column |
Ravindra Bagale's Tip
Interview line: “CALCULATE returns a scalar, CALCULATETABLE returns a table, and FILTER is the iterator I use when the condition is a measure. I filter VALUES of a column, not the fact table, unless I must.” Got it?
Ravindra Bagale's Tip – मराठी
मुलाखतीचे वाक्य: “CALCULATE संख्या देतो, CALCULATETABLE table देतो, आणि FILTER तो iterator आहे जो मी वापरतो जेव्हा अट measure असते. मी कॉलमच्या VALUES वर filter करतो, fact table वर नाही, जोपर्यंत सक्ती नसते.” समजलं का?
Ravindra Bagale's Tip – हिंदी
इंटरव्यू की लाइन: “CALCULATE संख्या देता है, CALCULATETABLE table देता है, और FILTER वह iterator है जिसे मैं तब इस्तेमाल करता हूँ जब शर्त measure हो. मैं कॉलम के VALUES पर filter करता हूँ, fact table पर नहीं, जब तक मजबूरी न हो.” समझ में आया?
Practice task
- Write
Sales 2025withCALCULATE. - Write
Cities AbovewithFILTERandCOUNTROWS. - Put City on a table and the flag measure beside it.
- Rewrite an Online filter that used
FILTER ( Sales, … )into a column filter. - Say which one is a table and which one is a number.
Got it? CALCULATETABLE changes context and returns a table. FILTER walks rows, usually a short list, when the test is a measure. Next: the patterns those pieces make together. Let's continue.
समजलं का? CALCULATETABLE context बदलतो आणि table परत देतो. FILTER rows वर चालतो, बहुतेक छोटी यादी, जेव्हा कसोटी measure असते. पुढे: हे तुकडे मिळून जे patterns बनतात. आता पुढे जाऊया.
समझ में आया? CALCULATETABLE context बदलता है और table वापस देता है. FILTER rows पर चलता है, अक्सर छोटी सूची, जब कसौटी measure हो. आगे: ये टुकड़े मिलकर जो patterns बनते हैं. आगे बढ़ते हैं.
Frequently asked questions
What does CALCULATETABLE return?
A table, evaluated in a modified filter context. It is the table sibling of CALCULATE, which returns a scalar.
What does FILTER return?
A table of the rows that pass a condition. It is an iterator. Wrap it in COUNTROWS, CALCULATE or another function that consumes a table.
When is FILTER the right tool?
When the condition uses a measure or logic that a simple column filter cannot express. Filter a small column list, not the whole fact table, when you can.
Can I put CALCULATETABLE on a card?
Not by itself — a card wants a scalar. Use CALCULATE for the number, or COUNTROWS of the table.
Same filter arguments as CALCULATE?
Yes. CALCULATETABLE accepts the same style of filter arguments, including patterns such as USERELATIONSHIP.
Course lessons?
FILTER, and the other useful functions table, in the DAX chapter.