Write DAX measures, calculated columns, and time intelligence functions
✓Works with OpenClaudeYou are a Power BI DAX expert. The user wants to write DAX measures, calculated columns, and time intelligence functions to enhance their Power BI data models.
What to check first
- Open the Power BI Desktop file and navigate to the Data view to see your tables and relationships
- Confirm your date table exists and is marked as a date table (right-click table → Mark as Date Table)
- Verify table relationships are set up correctly in the Model view — check cardinality and filter direction
Steps
- Create a simple measure by clicking New Measure in the Home ribbon and enter a DAX formula using
SUM(),COUNT(), orCALCULATE() - Use
CALCULATE()to modify filter context — wrap your aggregation with explicit filter conditions likeCALCULATE(SUM(Sales[Amount]), Year=2024) - Build a calculated column in the Data view by right-clicking a table and selecting New Column, then write row-by-row logic using
=(notMEASURE) - Implement year-to-date (YTD) using
TOTALYTD()function with your measure and date column:TOTALYTD(SUM(Sales[Amount]), Dates[Date]) - Add month-over-month growth by creating two measures — one for current month and one for prior month using
DATEADD(), then divide them - Use
FILTER()andALL()to override existing filters when you need to calculate against the entire dataset without restrictions - Create a dynamic time comparison measure using
SAMEPERIODLASTYEAR()to automatically compare current selection to same period last year - Test your measure in a visual and check the formula bar for syntax errors — use
Ctrl+Shift+Lto format DAX code for readability
Code
// Measure: Total Sales
Total Sales := SUM(Sales[Amount])
// Measure: Sales with explicit filter
Sales 2024 :=
CALCULATE(
SUM(Sales[Amount]),
YEAR(Sales[Date]) = 2024
)
// Measure: Year-to-Date Sales
YTD Sales :=
TOTALYTD(
SUM(Sales[Amount]),
Dates[Date]
)
// Measure: Prior Year Sales (for comparison)
Prior Year Sales :=
CALCULATE(
SUM(Sales[Amount]),
SAMEPERIODLASTYEAR(Dates[Date])
)
// Measure: Year-over-Year Growth %
YoY Growth % :=
DIVIDE(
[Total Sales] - [Prior Year Sales],
[Prior Year Sales],
0
) * 100
// Calculated Column: Full Customer Name (row context)
Full Name :=
Customers[FirstName] & " " & Customers[LastName]
// Measure: Average Sales per Transaction
Avg Transaction :=
DIVIDE(
SUM(Sales[Amount
Note: this example was truncated in the source. See the GitHub repo for the latest full version.
Common Pitfalls
- Treating this skill as a one-shot solution — most workflows need iteration and verification
- Skipping the verification steps — you don't know it worked until you measure
- Applying this skill without understanding the underlying problem — read the related docs first
When NOT to Use This Skill
- When a simpler manual approach would take less than 10 minutes
- On critical production systems without testing in staging first
- When you don't have permission or authorization to make these changes
How to Verify It Worked
- Run the verification steps documented above
- Compare the output against your expected baseline
- Check logs for any warnings or errors — silent failures are the worst kind
Production Considerations
- Test in staging before deploying to production
- Have a rollback plan — every change should be reversible
- Monitor the affected systems for at least 24 hours after the change
Related Power BI Skills
Other Claude Code skills in the same category — free to download.
Power BI Data Model
Design star schema data models with relationships and hierarchies
Power BI Report Design
Build interactive reports with visuals, slicers, bookmarks, and drillthrough
Power BI Power Query
Transform data with Power Query M language and advanced editor
Power BI Gateway
Configure on-premises data gateway for live connections
Power BI Row-Level Security
Implement RLS with DAX filter expressions and role mapping
Power BI Paginated Reports
Create pixel-perfect paginated reports with Report Builder
Power BI Embedded
Embed Power BI reports in custom applications with REST API
Want a Power BI skill personalized to YOUR project?
This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.