Dta102 - Bid102 - Day 2
Dta102 - Bid102 - Day 2
•One-to-One: Each record in one table matches one record in another table. Rare in
large datasets.
•One-to-Many: A record in one table can relate to many records in another. Most
common scenario in business databases.
•Many-to-One: Many records in one table match a single record in another.
Essentially the reverse of One-to-Many.
•Many-to-Many: Records in one table can relate to multiple records in another and
vice versa. Use cautiously as it can complicate the model.
CROSS FILTER DIRECTION
•Single Direction: Filters in one table affect the other table but not
vice versa.
•Both Directions: Filters in either table can affect the other, useful
in certain analytical scenarios but can lead to ambiguity and
performance issues.
BEST PRACTICES FOR
CREATING RELATIONSHIPS
•Ensure data types match between tables to establish accurate
relationships.
•Use primary keys whenever possible to ensure uniqueness and
reliability in relationships.
•Avoid creating unnecessary relationships that can complicate the
model and degrade performance.
INTRODUCTION TO DAX
DAX is a powerful formula language used in Power BI to create custom
calculations on data models. It includes functions, operators, and constants
that can be used in formulas. Some practical uses include:
Creating Calculated Columns: Use DAX to add new data based on existing
data in your model. Example is Total Sales = SUM(Sales[Amount])
Measures: Construct dynamic calculations that aggregate data based on
the filter context of the report. Average Transaction Size =
AVERAGE(Sales[TransactionSize])
Time Intelligence: Write formulas that help analyze data across time
periods easily. Year-to-Date Sales = TOTALYTD(SUM(Sales[Amount]),
'Date'[Date])
KEY DAX FUNCTIONS
CALCULATE: Changes the context in which data is evaluated, very powerful for
conditional sums and dynamic aggregations.
CALCULATE(expression, filter1, filter2,...): Example: Calculate total sales only for a
specific region.
SUM and AVERAGE:Adds up all the numbers in a column.
SUM(column_name): Example: Sum of sales in a fiscal quarter.
AVERAGE: Calculates the average of a column.
AVERAGE(column_name): Example: Average sales per transaction.
SOLVING BUSINESS
QUESTIONS WITH DAX:
Business Scenario: Determine the total sales made only on weekends.
Weekend Sales = CALCULATE(SUM(Sales[Total Sales]), Sales[Day] IN
{"Saturday", "Sunday"})
•Step-by-Step Calculation:
• Identify the total sales column.
• Apply a filter to include only sales from Saturday and Sunday.
• Sum the sales values filtered by these days.
THANK YOU FOR
LISTENING