Power BI - Simplifying Calculated Columns and Measures

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 


Measures:

Introduction-

If the requirement is to calculate an aggregate of many rows, then Measure is our best bet. These are dynamic in nature, meaning for each slicer/filter applied to the report, the measures are calculated on the go.

For example, we have a Region_Sales table as below:

Region_Name

Sales_Target

Sales_Achieved

North

1000

800

East

2000

1000

South

4000

1600

West

5000

500



The requirement is to calculate Achieved Sales %:

Achieved_Sales = Divide(Region_Sales[Sales_Achieved], Region_Sales[Sales_Target])

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