In Power BI, writing DAX (DATA ANALYSIS EXPRESSIONS) is all about creating Calculated Columns or Measures.
Let's try to break and simplify them:
Calculated Columns:
Introduction-
Calculated Columns are like any other columns in a table. They are like extension columns to your initial table, which are created using DAX inside Power BI.
For example, we have a table called Employee with columns - Employee_ID & Employee_Name:
|
Employee_ID |
Employee_Name |
|
1 |
aDam |
|
2 |
Bjorn |
|
3 |
GoergE |
|
4 |
Tim |
|
5 |
RoN |
The names of the employees are not entered in a proper format and the requirement is to CAPITALIZE them.
This can be achieved through multiple options, but as we are talking about Calculated Columns, let's create a new DAX column as follows:
Corrected_Name = UPPER(Employee[Employee_Name])
|
Employee_ID |
Employee_Name |
Corrected_Name |
|
1 |
aDam |
ADAM |
|
2 |
Bjorn |
BJORN |
|
3 |
GoergE |
GEORGE |
|
4 |
Tim |
TIM |
|
5 |
RoN |
RON |
This calculation is computed at each ROW LEVEL.
A Few Behaviors of Calculated Column(s)-
- Computed during Creation/Data Refresh
- Occupy space in the memory
- Represented by fx icon in the fields
|
Region_Name |
Sales_Target |
Sales_Achieved |
|
North |
1000 |
800 |
|
East |
2000 |
1000 |
|
South |
4000 |
1600 |
|
West |
5000 |
500 |
|
Region_Name |
Sales_Target |
Sales_Achieved |
Achieved_Sales |
|
North |
1000 |
800 |
80% |
|
East |
2000 |
1000 |
50% |
|
South |
4000 |
1600 |
40% |
|
West |
5000 |
500 |
10% |
A Few Behaviors of Measure(s)-
- Although a measure is created using a table columns, they do not belong to any of the tables in the dataset.
- Use CPU during the query time - Slicing/Cross filtering Visuals.
- Represented by a Calculator icon in the fields section