0% found this document useful (0 votes)
2 views

CH 2 Power BI-Filter and Data Analysis Expression (DAX) (1)

The document provides an overview of filtering techniques and DAX (Data Analysis Expressions) in Power BI, detailing various filter types such as slicers, visual filters, page filters, report-level filters, drill-through filters, and cross-report filters. It also introduces DAX, its syntax, data types, and calculation types, including measures and calculated columns, along with examples of common DAX functions. Additionally, it explains how to create tables and apply multiple filters using DAX.

Uploaded by

Vrushabh Taskar
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

CH 2 Power BI-Filter and Data Analysis Expression (DAX) (1)

The document provides an overview of filtering techniques and DAX (Data Analysis Expressions) in Power BI, detailing various filter types such as slicers, visual filters, page filters, report-level filters, drill-through filters, and cross-report filters. It also introduces DAX, its syntax, data types, and calculation types, including measures and calculated columns, along with examples of common DAX functions. Additionally, it explains how to create tables and apply multiple filters using DAX.

Uploaded by

Vrushabh Taskar
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 17

Filter and Data Analysis

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.

•Available as list or dropdown selections.


•Can filter data based on categorical fields like region, product category, or date.
•Support multi-selection and single-selection modes.
•Can be formatted and customized for better user experience.

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.

•Used to refine data within a specific visualization.


•Can be based on field values, conditions, or relative filters (e.g., Top 10 sales).
•Do not affect other visuals unless explicitly linked.

Example:
A bar chart showing "Top 5 Products by Sales" uses a visual filter to display only the top five
products.

3. Page Filters

Page filters apply to all visuals on a specific report page.


Used when a filter should impact multiple visuals but not the entire report.
Can be set up using fields from the data model.
Allows users to analyze data within the scope of a single page.

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

Report-level filters apply to all pages within a report.


Ensure consistency in data presentation across multiple report pages.
Useful for applying broad filters like a company-wide date range or
geographic region.
Applied in the "Filters" pane in Power BI.

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

Drill-through filters allow users to focus on specific details by navigating from a


summary page to a detailed report.

Enables deeper analysis of specific data points.

Users can right-click on a visual and select "Drill-through" to see related


details.

Requires setting up a dedicated drill-through page in Power BI.

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.

Allows users to maintain filter selections when navigating between reports.

Requires related reports to be published in the same workspace and have


common field relationships.

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.

Why Use DAX?


•Enables advanced calculations and aggregations beyond built-in Power BI capabilities.
•Supports computed columns and measures.
•Enhances data modeling with custom logic for KPIs, totals, and percentages.
2.2.2 Data Types in DAX
DAX supports different data types for performing calculations and analysis. The main data types
include:

1.Integer – Whole numbers (e.g., 100, -50).


2.Decimal (Floating-Point) – Numbers with decimal points (e.g., 10.5, 3.14).
3.Boolean – TRUE or FALSE values.
4.String (Text) – Alphanumeric characters (e.g., "Sales", "Customer Name").
5.Date/Time – Date and time values (e.g., "2024-02-26 10:30 AM").
6.Currency – Similar to decimal but formatted as currency.
7.Variant (Blank) – Represents missing or NULL values.
Example:
If a column contains sales amounts (e.g., 5000, 7500.5), it is stored as a Decimal type.
2.2.3 DAX Formula – Syntax
DAX formulas consist of functions, operators, and values. The basic syntax follows this structure:

Measure_Name = Function_Name(Arguments)

Key Elements in DAX Syntax:


1.Measures & Calculated Columns
•Measures perform calculations on data dynamically (e.g., Total Sales, Average Profit).
•Calculated Columns create new columns in a table based on existing data.
2.Operators
•Arithmetic: +, -, *, / (e.g., [Sales] * 0.1 for 10% commission).
•Comparison: =, <>, >, < (e.g., [Revenue] > 10000).
•Logical: AND(), OR(), NOT() (e.g., IF([Sales] > 5000, "High", "Low")).

3.Common DAX Functions:


•SUM() – Adds up values in a column.
Total_Sales = SUM(Sales[Amount])

•AVERAGE() – Calculates the average of a column.


Avg_Price = AVERAGE(Products[Price])
IF() – Conditional logic.

Sales_Category = IF(Sales[Amount] > 5000, "High", "Low")

COUNT() – Counts rows in a column.

Customer_Count = COUNT(Customers[CustomerID])

RELATED() – Fetches related data from another table.


CALCULATE() – Modifies context of calculations.
2.2.4 DAX Calculation Types
DAX allows different types of calculations to enhance data analysis. The two main types are:

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])

3. Row Context vs. Filter Context


•Row Context: Applied when working with row-wise calculations (e.g., Calculated Columns).

•Filter Context: Applied dynamically based on selected filters (e.g., Measures).


2.2.5 Steps to Create Calculated Columns

1.Open Power BI and load your dataset.


2.Go to the "Data" or "Modeling" tab.
3.Click on "New Column."
4.Enter the DAX formula in the formula bar.
5.Press Enter, and the new column will be added to the table.
6.Use the calculated column in reports and visualizations.

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.

Steps to Create a Measure:


1.Open Power BI and go to "Modeling."
2.Click on "New Measure."
3.Enter the DAX formula.
4.Press Enter, and the measure is created.
5.Use the measure in visualizations.

Total_Profit = SUM(Sales[Revenue]) - SUM(Sales[Cost])


2.2.7 DAX Functions

DAX provides built-in functions for various calculations.


1. Aggregation Functions
•SUM(), AVERAGE(), MIN(), MAX(), COUNT(), COUNTROWS().

2. Logical Functions
•IF(), AND(), OR(), NOT(), SWITCH().

Sales_Category = IF(Sales[Amount] > 5000, "High", "Low")

3. Time Intelligence Functions


TOTALYTD(), DATESYTD(), PREVIOUSMONTH(), NEXTYEAR().

Total_YTD = TOTALYTD(SUM(Sales[Revenue]), Sales[Date])


4. Filter Functions
•FILTER(), CALCULATE(), ALL(), RELATED().

Filtered_Sales = CALCULATE(SUM(Sales[Amount]), Sales[Category] = "Electronics")


2.9 DAX Tables and Filtering
DAX provides various functions to create tables and filter data dynamically in Power BI.

1. Creating Tables Using DAX


DAX allows creating virtual tables inside measures and calculated tables.

•SUMMARIZE() – Creates a summary table.


•ADDCOLUMNS() – Adds calculated columns to a table.
•SELECTCOLUMNS() – Returns specific columns from a table.

Example: Creating a Summary Table of Sales by Category

Summary_Table = SUMMARIZE(Sales, Sales[Category], "Total Sales", SUM(Sales[Amount]))

Combining Multiple Filters in DAX


DAX allows combining multiple filtering conditions using CALCULATE() and FILTER().

Example: Get Sales for "Electronics" Category in "North" Region

Electronics_North_Sales = CALCULATE(SUM(Sales[Amount]),
Sales[Category] = "Electronics",
Sales[Region] = "North")

You might also like