---
type: learning
area: learning
status: learning
date: 2026-05-03
created: 2026-05-03
updated: 1980-01-01
tags:
  - learning
---
![[img-20250705-093726-4b4cf28c.png]]
# DAX Performance Tip: VALUES + COUNTROWS vs DISTINCTCOUNT

## The Pattern

```dax
// Instead of:
DISTINCTCOUNT('Table'[Column])

// Use:
COUNTROWS(VALUES('Table'[Column]))
```

## How It Works

- **VALUES()** → Creates table of unique values only
- **COUNTROWS()** → Counts rows in that unique values table
- **Result** → Same as DISTINCTCOUNT but faster

## Why It's Faster

- Separates deduplication from counting
- DAX engine optimizes each step independently
- VALUES() leverages existing indexes/relationships better
- COUNTROWS() is extremely fast on pre-filtered tables

## When to Use

✅ Large datasets (1M+ rows)  
✅ Performance-critical measures  
✅ When you need the VALUES table for other calculations

## Key Insight

Breaking complex operations into simpler atomic operations often performs better in DAX.

---
![[img-20250705-234335-4b7db374.png]]
![[img-20250706-001518-75b694a1.png]]
Calculated columsna re stored with data they take space , so every time tables is called they are updated

## Conversion Functions
![[img-20250706-130322-2f4dff27.png]]
#### COALESCE() Function:
![[img-20250706-215950-9e3258da.png]]

![[img-20250706-220154-b179a5ba.png]]