Back to Blog

5 DAX Hacks to Stop the "Loading" Nightmare ⚡

DAX Optimization

Nobody likes a slow dashboard. If your users are staring at loading dots for 10 seconds, you’ve already lost them. The fix? You don't need a supercomputer. You just need to break a few bad habits.

Here are 5 quick wins to make your Power BI reports fly.

1. Stop Doing Double Math (Use VAR)

Writing the same calculation twice in one measure? Stop it. Power BI has to do the math every single time.

The Fix Use VAR. It calculates the number once, saves it, and reuses it. It makes your code cleaner and your report instant.
The Slow Way:
Profit Margin = 
(SUM(Sales[TotalAmount]) - SUM(Sales[TotalCost])) / SUM(Sales[TotalAmount])
The Fast Way (with VAR):
Profit Margin = 
VAR TotalSales = SUM(Sales[TotalAmount])
VAR TotalCost = SUM(Sales[TotalCost])
RETURN
DIVIDE(TotalSales - TotalCost, TotalSales)

2. Don’t Be a Memory Hog

This is the classic rookie mistake: filtering an entire table when you only need one column.

The Fix When using FILTER, be specific. Don't grab the whole Sales table; just grab the Region column. If you filter the whole table, the engine has to scan every single column, which eats up memory like crazy.
The Slow Way:
Europe Sales = 
CALCULATE(
    [Total Sales],
    FILTER('Sales', 'Sales'[Region] = "Europe") // Scans the entire table!
)
The Fast Way:
Europe Sales = 
CALCULATE(
    [Total Sales],
    KEEPFILTERS('Sales'[Region] = "Europe") // Better, or use FILTER on the column only
)
// OR
// CALCULATE([Total Sales], FILTER(ALL('Sales'[Region]), 'Sales'[Region] = "Europe"))

3. The Safe Way to Divide

Using the slash symbol (/) is fast to type, but it’s risky. If you accidentally divide by zero? Your measure breaks or returns infinity errors.

The Fix Use the DIVIDE function. It handles those "divide by zero" errors automatically and is optimized to run smoother in the background.
The Risky Way:
Avg Price = SUM(Sales[TotalAmount]) / SUM(Sales[Quantity])
The Safe Way:
Avg Price = DIVIDE(SUM(Sales[TotalAmount]), SUM(Sales[Quantity]))

4. Count Smarter, Not Harder

Need to know how many sales happened? Don't use COUNT. It wastes time checking every single cell to see if it's empty.

The Fix Use COUNTROWS. It ignores the data inside the cells and just looks at the table structure. It’s a tiny switch that gives you a huge speed boost.
The Slow Way:
Total Transactions = COUNT('Sales'[SalesOrderNumber])
The Fast Way:
Total Transactions = COUNTROWS('Sales')

5. Fix the Foundation (Star Schema)

You can write the best code in the world, but if your data model looks like a bowl of spaghetti, your report will struggle.

The Fix Keep it simple. Use a Star Schema. Keep your fact tables (data) skinny and your dimension tables (lookups) wide. If the model is clean, the DAX is fast.
The "Spaghetti" Model:

A single, giant table with 100+ columns containing Customer Name, Product Category, Order Date, Sales Amount, etc., all mixed together.

The Star Schema:

Fact Table: 'Sales' (Order ID, DateKey, CustomerKey, ProductKey, Quantity, Amount)
Dimension Tables: 'DimCustomer', 'DimProduct', 'DimDate' linked via keys.


The Bottom Line

Speed isn't magic. It's just cleaner code. Try these out today and watch that loading nightmare disappear. 🚀