How to add a calculated column in Power BI [SUPER GUIDE]

by Milan Stanojevic
Milan Stanojevic
Milan Stanojevic
Windows & Software Expert
Milan has been enthusiastic about technology ever since his childhood days, and this led him to take interest in all PC-related technologies. He's a PC enthusiast and he... read more
Affiliate Disclosure
power bi calculated columns measures
XINSTALL BY CLICKING THE DOWNLOAD FILE
To fix various PC problems, we recommend DriverFix:
This software will keep your drivers up and running, thus keeping you safe from common computer errors and hardware failure. Check all your drivers now in 3 easy steps:

  1. Download DriverFix (verified download file).
  2. Click Start Scan to find all problematic drivers.
  3. Click Update Drivers to get new versions and avoid system malfunctionings.
  • DriverFix has been downloaded by 0 readers this month.

Power BI is an incredibly useful tool when it comes to making calculations. However, quite a few users are encountering issues with adding a calculated column in Power BI.

One user described the problem on the official forum:

I’m quite new with Power Bi and i am using a matrix to group my data like this (image below). Now I want to add a new column which allow me to make a new calculation = ([q’ty per unit of 3rd month] – [q’ty per unit of 2nd month]) * [Price per Unit of 3rd month]
Is there any simple way help me to do so since I’m not an expect with DAX. Thanks for your help.

power bi column example
So, the OP wants to add a new column that will allow a new calculation. Today we will show you how to do that in a few easy steps.

Steps to add a calculated column in Power BI

1. Create a measure using DAX

DAX stands for Data Analysis Expression and it is the formula language in Power BI. Here you can add functions and formulas for your columns like in the image below.

power bi dax function
In the upper case (second arrow), add the following:

Result =
VAR qty_per_unit_of_3rd_month =
CALCULATE ( MAX ( Table[q’ty per unit] ), FILTER ( Table, Table[Month] = 3 ) )
VAR qty_per_unit_of_2rd_month =
CALCULATE ( MAX ( Table[q’ty per unit] ), FILTER ( Table, Table[Month] = 2 ) )
VAR Price_per_Unit_of_3rd_month =
CALCULATE ( MAX ( Table[Price per Unit] ), FILTER ( Table, Table[Month] = 3 ) )
RETURN
qty_per_unit_of_3rd_month – qty_per_unit_of_2rd_month * Price_per_Unit_of_3rd_month

Adapt the values to make the formulas work for your case.


This guide will make you a better Power BI user. Do check it out now.


2. Apply the measure directly to the slicer

You can also modify the measure as below:

Result =
VAR
qty_per_unit_of_first_month_in_slicer =
CALCULATE ( MIN ( Table[q’ty per unit] ), ALLSELECTED ( Table ) )
VAR
qty_per_unit_of_last_month_in_slicer =
CALCULATE ( MAX ( Table[q’ty per unit] ), ALLSELECTED ( Table ) )
VAR
Price_per_Unit_of_last_month =
CALCULATE (
MAX ( Table[Price per Unit] ),
FILTER ( Table, Table[Month] = qty_per_unit_of_last_month_in_slicer )
)
RETURN
qty_per_unit_of_last_month_in_slicer – qty_per_unit_of_first_month_in_slicer * Price_per_Unit_of_last_month

The second measure applies directly to the slicer, so you can compare different months, such as the first and the last.

Conclusion

With calculated columns, you can organize and visualize your data in various ways. But first, you need to know a few basic principles and measures for these columns. They are pretty easy to work with once you get to understand them.

How do you add calculated columns in Power BI? Do let us know in the comments section below!

RELATED ARTICLES YOU NEED TO CHECK OUT:

Still having issues? Fix them with this tool:

SPONSORED

If the advices above haven't solved your issue, your PC may experience deeper Windows problems. We recommend downloading this PC Repair tool (rated Great on TrustPilot.com) to easily address them. After installation, simply click the Start Scan button and then press on Repair All.

This article covers:Topics: