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

DAX-1 (4)

The document provides an overview of DAX (Data Analysis Expression) in Power BI, detailing the creation of calculated columns, measures, and tables. It emphasizes the importance of data types, particularly for date values, and discusses the use of variables to simplify calculations and improve performance. Additionally, it covers various DAX functions, filter contexts, and methods for modifying filter contexts to enhance data analysis capabilities.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

DAX-1 (4)

The document provides an overview of DAX (Data Analysis Expression) in Power BI, detailing the creation of calculated columns, measures, and tables. It emphasizes the importance of data types, particularly for date values, and discusses the use of variables to simplify calculations and improve performance. Additionally, it covers various DAX functions, filter contexts, and methods for modifying filter contexts to enhance data analysis capabilities.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 59

DAX: Data Analysis Expression

3 things u can create using DAX.They are


​ 1.Calculated column
​ 2.Measures
​ 3.Calculated table
[Ultimate] Guide of Power BI Dax Function for Begineers | Basics of Power BI Dax
Use the site and Refer it
Datatype

Date type is important. If datatype of any datevalue is text means, u cant extract
month or year from the date. It needs to be described as date datatype

How to change the datatype?


U can select the date format too​

In data modelling too, we can change the format of the data​

In power query editor also, we can change the data type


​ To simply the complex calculation, we use variables. And u can use any no of
times that variable in your calculation

Problem statement:
% change in sales of 4-jan-2025 and 1-jan-2025

%change=(current_year-previous year)/previous_year
U created 3 measures for finding % change. This can be avoided by using variables

Readability of this measures is complex.


If i need the value in my measures multiple times, then go for variables

Now performance has improved. Because same calculation is not happening multiple
times
Concatenation operator
Comparison operator always returns true or false based on the condition
AND

Whenever u want multiple condition to be true, use AND​

AND
OR​

Concatenation​

IN operator​
ISBLANK​

AND
OR​

NOT​

TRUE​

IF
Conditional column

Explain conditional column and custom column in both DAX and power query editor
Nested IF

Nested IF with AND operator

When u divide anything by 0, u get infinitive​


IFERROR

SWITCH​
AVERAGE

Average function is not able to handle non-numeric or text values

AVERAGEA
AVERAGEX
Important Filter Functions in DAX in Power BI - Slidescope
Filter function never allow you to filter the values from another table though it has
relationship with another table

Calculate vs calculatetable​
Filter function and calculatetable function​
Calculate function will modify the existing filter context

Evaluation order of calculate function

First filtering then calculation take place in the above query


We can modify the filters filter modification function
ALL​

All function is going to remove all filters that is applied on the visual
All filter will remove the implicit filters as well as explicit filters

ALLEXCEPT​

Allexcept keep only one filter mentioned within allexcept function. Ignore any other filters applied on the
page
Find %of contribution of each country in sales amount by occupation?
​ For that use ALLEXCEPT

Rank function
Filter

Where sales is physical table

Where values(sales[orderDate]) is a virtual table


One condition on calculate function​

Multiple condition on calculate function (and condition)​


Multiple condition on calculate function(or condition)​

Effect of using filter function

When we use direct filter in the calculate function, it will override the filter context. Hence it
display values in all countries irrespective of filter context.

Internal filter context is applied when we use filter function


MAX,MAXX,MAXA,MIN,MINX,MINA and iterator function
Here context transition is not happening
Here when we use calculate function , we get context transition. So it gives best selling amt

Filter context:
​ Sometimes u want to modify the filter context
Filter types
Visual level
Page level
Report level

Difference between slicer and filter


Difference between row context and filter context
Tell about calculate function with all,allselected, allexcept

Filter context
​ 1.visual filter/inside filter
​ 2.outside filter

To modify filter context, we can use functions like


ALL,ALLEXCEPT,ALLSELECTED,REMOVEALLFILTERS
Row selection and column selection above

Slicer filtering values

This filtering pipe symbol helps to know what filter u use in your visual
Calculate function
​ Calculate is the only function which will override the filter context.
​ We will give filter criteria within the calculate function
Modifying filter context:
Student table

Adding 2 months​
Adding 2 months, additioinal criteria​

Remove filters

Note: in right side,all months and year are static value but cc group and GL group works as
per filters context

ALL works
Same as remove filters
ALL​

AllSelected()
​ It removes only visual filter and consider outside filter
AllEXCEPT​

Measures is not part of data modeling


Do Custom sort?
Learn-conditional column in power query editor
Learn column chart
Custom sorting
Learn if condition in dax
Learn line chart for trend analysis
Us fiscal month - oct to sep
India fiscal month- apr to mar
US fiscal month

India fiscal month​


Using visual level filter​

Using dax​ ​ ​ using filters


Values function
​ Values function will give unique values from the column

We count unique values

Running total
Topn
Rankx
Filter
Calculate
Calendar auto dax function

TotalQTD

TotalYTD​

TotalMTD​

What is the difference between reference and duplicate?


Reference

Duplicates

For that there are certain things needs to be done


1.​ Create calendar table using dax function and extract month from that
​ calendar_table=calendar(min(sales[order_date]),max(sales[order_date]))
Where min and max represent sales start_date and sales end_date
2.​ Create data modeling (connect calendar table with sales table to get sales value)
3.​ Create line chart and assign x-axis and y-axis

How to highlight max value and min value in line chart?


​ U need to write a measure to find max value and one measure for finding min
value
Ordered no

Descending​
To highlight the min and max value
For line chart too, Do the same following

You might also like