CH 2 Power BI-Filter and Data Analysis Expression (DAX) (1)
CH 2 Power BI-Filter and Data Analysis Expression (DAX) (1)
Expression (DAX)
Notes By – Prof. Ved Shintre
1. Slicers
Slicers are visual tools that allow users to filter data dynamically. They provide a user-friendly way
to interact with reports and dashboards.
Example:
A sales report with a slicer for "Region" enables users to filter data based on selected regions.
Sliced Data (as per Product Type)
2. Visual Filters
Visual filters apply to a single visual (chart, table, or graph) on a report page.
Example:
A bar chart showing "Top 5 Products by Sales" uses a visual filter to display only the top five
products.
3. Page Filters
Example:
A dashboard with sales data can have a page filter for "Year = 2023" to display only that
year's data across all visuals on that page.
4. Report-Level Filters
Example:
A company-wide sales report may have a report-level filter for "Country
= USA" to show data only from the United States.
5. Drill-Through Filters
Example:
A high-level sales report may allow users to drill through on a "Product" field to
view detailed transactions related to that product.
6. Cross-Report Filters
Cross-report filters enable filtering data across multiple reports within Power
BI.
Example:
A sales performance report may pass filter selections (e.g., selected region)
to a separate customer analysis report.
2.2.1 Introduction to DAX
What is DAX?
•DAX stands for Data Analysis Expressions.
•It is a collection of functions, operators, and constants used to define custom calculations in
Power BI.
•Similar to Excel formulas but designed for relational data models and large datasets.
Measure_Name = Function_Name(Arguments)
Customer_Count = COUNT(Customers[CustomerID])
1. Calculated Columns
•Created at the table level and stored as part of the dataset.
•Computed row by row using existing columns.
•Takes up storage space as it becomes part of the model.
Example: Adding a "Profit" column to a Sales table.
Profit = Sales[Revenue] - Sales[Cost]
2. Measures
•Calculated dynamically at the time of analysis.
•Do not take up storage space as they are computed on the fly.
•Used in reports, visualizations, and aggregations.
Example: Calculating total sales dynamically.
Total_Sales = SUM(Sales[Amount])
Example: Creating a Full Name column from First and Last Name.
Full_Name = Customers[FirstName] & " " & Customers[LastName]
2.2.6 Measures in DAX
Measures are used to calculate aggregated values dynamically.
Key Features of Measures
•Not stored in tables but computed during analysis.
•Uses filter context to calculate values dynamically.
•Used in dashboards, reports, and visualizations.
2. Logical Functions
•IF(), AND(), OR(), NOT(), SWITCH().
Electronics_North_Sales = CALCULATE(SUM(Sales[Amount]),
Sales[Category] = "Electronics",
Sales[Region] = "North")