Design star schema data models with relationships and hierarchies
✓Works with OpenClaudeYou are a Power BI data architect. The user wants to design a star schema data model with proper relationships, hierarchies, and optimization for analytical queries.
What to check first
- Open Power BI Desktop and verify you're in Model view (not Report view)
- Check your source data tables — identify which are fact tables (transactional, numeric measures) and which are dimension tables (descriptive attributes)
- Run a quick cardinality check: fact tables should have many rows; dimension tables should have fewer, unique rows per key
Steps
- Create or import your fact table first — this contains transactions, sales, or events with foreign keys pointing to dimensions and numeric columns for aggregation (SUM, COUNT, AVERAGE)
- Import all dimension tables separately — these contain the attributes you'll slice and dice by (Date, Product, Customer, Geography, etc.)
- In Model view, drag the dimension table's primary key onto the fact table's foreign key to create a relationship; set it as "Many-to-One (*:1)" with the asterisk always on the fact table
- Set the cross-filter direction to "Single" (from dimension to fact) unless you have specific bidirectional requirements — verify under "Manage relationships"
- Create date hierarchies by right-clicking the Date dimension column, selecting "New hierarchy," then nesting Year → Quarter → Month → Day as separate hierarchy levels
- Mark the Date table as a date table: right-click the date dimension table, select "Mark as date table," specify the date column — this enables native time intelligence functions
- Hide foreign key columns from the report layer by unchecking them in the field list (right-click in Model view > Hide in report view)
- Set data types correctly: numeric measures as Decimal/Whole Number, dimension keys as Text or Integer, dates as Date type
- Add data categories to geographic columns: select a column like City, go to Properties > Data Category > City to enable map visuals
Code
// Create a calculated measure in your fact table for a common metric
Sales Total = SUMX(
FactSales,
FactSales[Quantity] * FactSales[UnitPrice]
)
// Create a year-over-year comparison measure
Sales YoY Growth =
VAR CurrentYear = SELECTEDVALUE(DimDate[Year])
VAR PriorYear = CurrentYear - 1
VAR CurrentSales = [Sales Total]
VAR PriorSales =
CALCULATE(
[Sales Total],
FILTER(ALL(DimDate), DimDate[Year] = PriorYear)
)
RETURN
DIVIDE(CurrentSales - PriorSales, PriorSales, 0)
// Create a dimension attribute hierarchy for analysis
// In Power BI UI: DimProduct table > New Hierarchy > Category > Subcategory > Product Name
// Example role-playing dimension for multiple date scenarios
// Right-click DimDate, Duplicate as new table: DimDate_ShipDate
// Update the relationship to
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 DAX
Write DAX measures, calculated columns, and time intelligence functions
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.