Select your country to view prices and course dates.

x

Recent Searches
Category

Microsoft Copilot Courses

Category

Microsoft Power BI

Category

AI for Business

Category

Microsoft Excel

Category

Professional Development

Category

Microsoft Office 365

Category

Excel Specialist

Category

Microsoft Project

Category

R Programming

Category

Python

Category

SQL

Category

Power Apps

Category

SharePoint

Category

Power Automate

Category

Microsoft Teams

Category

Microsoft Visio

Category

Microsoft PowerPoint

Category

Microsoft Word

Category

Microsoft Outlook

Category

Adobe InDesign Courses

Category

Adobe Photoshop Courses

Category

Adobe Illustrator Courses

Category

Adobe Premiere Pro Training

Category

Adobe After Effects Training

Category

Adobe Acrobat Courses

Category

Adobe Captivate Training

Category

Adobe Animate Training

Category

HTML Courses

Category

WordPress

Category

Canva Courses

Category

Microsoft Access

Category

Webinars

Course

Copilot for M365

Course

Power BI Beginner

Course

ChatGPT Beginner

Course

Excel Beginner

Course

Achieving Leadership & Success

Course

Microsoft 365 Beginner

Course

Financial Modelling

Course

Project Beginner

Course

R Programming Beginner

Course

Python Beginner

Course

SQL Beginner

Course

Power Apps Beginner

Course

SharePoint Beginner

Course

Teams Essentials

Course

Visio Essentials

Course

PowerPoint Level 1

Course

Word Beginner

Course

Microsoft Outlook Beginner

Course

InDesign Lite

Course

Photoshop Training Intro

Course

Illustrator Training Intro

Course

Premiere Training Intro

Course

After Effects Training Intro

Course

Acrobat Essentials

Course

Captivate Training

Course

Animate Training Intro

Course

HTML Training Intro

Course

WordPress Essentials

Course

Canva Beginners

Course

Microsoft Access Essentials

Course

Copilot for Word

Course

Power BI Intermediate

Course

Excel Intermediate

Course

Microsoft 365 Intermediate

Course

Analysis and Dashboards

Course

Project Intermediate

Course

R Programming Intermediate

Course

Python Intermediate

Course

SQL Intermediate

Course

Power Apps Intermediate

Course

SharePoint Intermediate

Course

PowerPoint Level 2

Course

Word Intermediate

Course

InDesign Training Intro

Course

Photoshop Lite

Course

Illustrator Training Advanced

Course

Premiere Basics Training

Course

Acrobat Forms

Course

Canva Intermediate

Course

Microsoft Access Advanced

Course

Copilot for Excel

Course

Power BI Advanced

Course

Excel Advanced

Course

Microsoft 365 Advanced

Course

Excel VBA

Course

Project Advanced

Course

R Programming Advanced

Course

Python Advanced

Course

SQL Advanced

Course

Power Apps Advanced

Course

SharePoint Advanced (Site Owner)

Course

Word Advanced

Course

InDesign Training Advanced

Course

Photoshop Training Advanced

Course

Advanced Premiere Training

Course

Advanced After Effects Training

Course

Canva Advanced

Course

Copilot for PowerPoint

Course

Power BI DAX

Course

Excel Expert

Course

Machine Learning in R

Course

SharePoint Advanced (Document Governance)

Course

InDesign Interactivity Training

Course

Copilot for Outlook and Teams

Course

InDesign Accessibility Training

Course

Power Automate Beginner

Course

Power Automate Intermediate

Course

Microsoft Outlook Advanced

Course

AI Prompting Fundamentals

Course

Power Automate Advanced

Course

Excel Tables and Pivot Tables

Course

Data Transformation with Power Query

Course

Excel Macro Mastery

Course

Power BI Desktop Advanced Reporting

Course

AI for Business Leaders and Managers

Course

Data Visualisation with Power BI Desktop

Course

Anger Management & Negotiation Skills

Course

Assertiveness & Confidence

Course

Building Resilience

Course

Coaching and Mentoring

Course

Communications

Course

Communications & Quality Client Service Training

Course

Critical Thinking and Problem Solving

Course

Cultural Diversity in the Workplace

Course

Embracing Change

Course

Growing Emotional Intelligence

Course

Minute Taking

Course

Persuasion and Negotiation Skills

Course

Presentation Skills and Public Speaking

Course

Practical Project Management

Course

Respect, Equity and Diversity (RED)

Course

Resumé Writing and Interview Skills

Course

Stress Management

Course

Team Leadership, Management and Development

Course

Time Management Intensive

Course

Train the Trainer

Course

Write Effective Business Documents

Course

Dealing with Difficult People

Course

Managing Difficult Conversations

Course

Managing the Virtual Workplace

How To Change A Formula In Power BI

| May 16, 2022
power BI tips header

Power BI Formulas

Microsoft Power BI is a fantastic interactive data visualisation software that focuses on business intelligence. It's a collection of applications, software services, and connectors working together to transform unrelated data sources into coherent, visually immersive, and interactive insights. 

Have you ever gotten stuck in a situation involving a dataset and wanted to work around various formulas by adding, removing, or modifying them? Sometimes we might want to find, change and replace formulas. So you may wonder, "how do I change the power BI formula?" or "Is there a Find and replace function in Power BI?" or "What is a  measure, and how do you modify a measure in Power BI?". Let us discuss how to handle these situations. 

Assuming you have loaded your dataset, Let us begin. 

 

The Formula Bar in Power Query Editor

Power BI provides us with a Power-Query formula bar. Let's go step by step and explore Formula Bar in Power Query Editor:

Go to File on the top left ribbon menu:

power bi formula change

 

Go to Options and Settings:

power bi formula change

 

Click the option "Display the Formula Bar" in "Options and Settings".

power bi display the formula bar

 

Now you can see the Formula Bar in the Query Editor.

change formula power bi

Source

 

Formulas perform all query transformations in Power Query. A formula is added to the formula bar as you use the Query Editor builders. You may want to add a formula other than those associated with a builder, or you may want to alter an existing formula.

power bi transform table

Before we go deeper, we need to know the difference between DAX and M Language.

 

What Is The Difference Between DAX and M Language?

There are two languages that Microsoft Power BI uses to transform, filter, manage, and visualize data; M language and DAX (Data Analysis Expression).

M language can be considered as a query formula language used in the Power BI Query Editor to prepare data before it can be loaded into the Power BI model. In contrast, DAX is an analytical data calculation language used for in-depth data analysis during the Data View phase. 

power bi formula bar

The measure/column tool additionally provides all the information related to the measure or column, respectively. A DAX expression consists of a formula followed by a measure or a column reference.

 

How To Add a Formula to a Power BI Query

Queries can be added to formulas in Power BI. When we create a formula, Power Query validates the formula syntax. When we insert or delete an intermediate step in a query, we might potentially break a query. Power Query will display an 'Insert Step' warning when we try to insert a new step.

Let us go through the procedure to add a formula to a query:

  1. In the query step pane, select the step you want to precede the new step (formula) immediately.
  2. Click the function or fx icon to the left of the formula bar. A new formula is created in the form = <nameOfTheStepToReference>. For example, = Production.Work.Order.
  3. Type in the new formula in the format = Class.Function(ReferenceStep[,other-parameters]).
  4. For instance, you have a table with the column Gender, and you want to add a column with the value "Ms." or "Mr." depending on the person's gender. The formula would be = Table.AddColumn(<ReferencedStep>, "Prefix", each if [Gender] = "F" then "Ms." else "Mr.")

table add column power bi

 

Creating Calculated Column

To create Calculated Columns:

  1. Right-click on the Table.
  2. Click on New Column.

creating calculated column

Let's get Product Cost in the Sales Table from the Product Table.

  1. Type in the following DAX formula in Formula Bar: Product Cost (CC) = RELATED('Product Table'[Product Cost])

Now, Let's Create a Revenue column by multiplying the Quantity Sold by the Sale Price.

  1. Right-click on the Sales Table.
  2. Click on New Column.
  3. Type in the following DAX formula in Formula Bar.

Revenue (CC) = 'Sales Table'[Quantity Sold]*'Sales Table'[Sale Price]

Now let's create a Total Cost column by multiplying Quantity Sold by Product Cost.

  1. Right-click on the Sales Table.
  2. Click on New Column.
  3. Type in the following DAX formula in Formula Bar: Total Cost (CC) = 'Sales Table'[Quantity Sold]*'Sales Table'[Product Cost (CC)]

All three columns, i.e., the Total Cost (CC) column, Revenue (CC) column, and Product Cost (CC) column, have been created, giving values for which row of the Table.

how to change a formula in power bi

Calculated Columns have a distinct icon, as seen in the screenshot, to differentiate them from other data entities.

power bi claculated column label

How To Edit Power BI Formula

Two ways to change the Power BI formula are firstly using the formula's dialog box and secondly in the formula bar.

 Edit a formula using the formula's dialog box

  1. In the query step pane, right-click the step you want to edit.
  2. From the context menu, select Edit Settings.
  3. In the dialog box, edit the formula.

Edit a formula in the formula bar

  1. In the query step pane, select the step you want to edit.
  2. In the formula bar, locate and change the parameter values to the values you want.
  3. Click Refresh.

 

The Query-Editor appears when you load, edit, or create a new query using Power Query. To view the Query Editor without loading or editing an existing query on the workbook, select From Other Sources >> Blank Query, from the Get External Data section in the Power Query ribbon tab. 

 

Power BI Filter Formula

Creating a Filter on a Table used in a Formula

Power BI allows us to apply filters in formulas that take tables as an input. So instead of entering table names, we can use the FILTER function to define a subset of rows from the Table. That subset can be passed to another function for various operations like custom aggregations.

For example, suppose we have a data table containing order information about resellers, and we like to calculate the formula for sales from each reseller. However, we want to show the sales amount just for the resellers who sold multiple units of high-value products. 

Based on the Power BI DAX sample workbook, using the filter formula, we can create the calculation:

=SUMX(FILTER ('ResellerSales_EURO', 'ResellerSales_EURO'[Quantity] > 10 &&

     'ResellerSales_EURO'[ProductStandardCost_EURO] > 200),

     'ResellerSales_EURO'[SalesAmount])

 

change formula power bi

 

Functions that return a table, such as FILTER, will never directly return the rows or Table but will always be embedded in another function. 

change formula power bi

 

The FILTER expression is affected by the context where it is used e.g. if we use FILTER in a measure, and the measure is used in a PivotChart or PivotTable, the subset of data returned may be affected by additional filters or Slicers that the user has applied in the PivotTable. 

 

How To Use Replace Function in Power BI?

Replace function in DAX allows us to replace part of a text string, based on the number of characters specified, with another text string. MS Excel has different functions to use with single-byte and double-byte character languages but DAX uses Unicode. Therefore DAX stores all characters as the same length. Replace function is not supported in DirectQuery mode when used in row-level security (RLS) rules or calculated columns.

A typical Replace Function syntax looks like this:

REPLACE(<old_text>, <start_num>, <num_chars>, <new_text>)

For instance, to create a new calculated column replacing the first two characters of the product code [ProductCode] column, with a new two-letter code, OB, we will use the following formula:

= REPLACE('New Products'[Product Code],1,2,"OB")

 

formula change power bi

 

How is SUBSTITUTE different from REPLACE?

Substitute Function will replace existing text with new text in a text string. We use the SUBSTITUTE function when we want to replace specific text in a text string. We use the REPLACE function when we want to replace any text of variable length which occurs in a specific location in a string of text. SUBSTITUTE-function is case-sensitive i.e. if case does not match between text and old_text, SUBSTITUTE will not replace the given text. It is not supported in DirectQuery mode when used in row-level security (RLS) rules or calculated columns.

The syntax appears like this:

SUBSTITUTE(<text>, <old_text>, <new_text>, <instance_num>)

To make a copy of the column [Product Code] to substitute the new product code NW for the old product code PA when it occurs in the column, we will use the following code:

= SUBSTITUTE([Product Code], "NW", "PA")

 

Conclusion

Power BI is one of the best tools in the Data Science and Analytics industry. If you want to be the best you need hands-on experience with Power BI. Attend one of our many courses to become acquainted. Courses range from beginner to DAX and are offered remotely across Asia. 

Trusted Globally by Leading Organisations

At Nexacu, we are proud to be the trusted training partner for hundreds of leading organisations across Australia, New Zealand, and around the world. From government agencies to multinational corporations, we help teams build practical skills and achieve real outcomes through expert-led training.

  • 400+ companies rely on Nexacu for workforce development
  • Trusted by government agencies at all levels
  • Delivering training across 9 countries and growing

Why Nexacu? 

step by step courseware

Step by Step Courseware

Custom workbook included with a step by step exercises

Facility Image 2
Facility Image 3
Facility Image 1

Interactive real time training

Interactive, Real-Time Training

Learn with expert instructors, wherever you are

Trusted by Business

Trusted by Business

Procured by Government

Procured by Goverment

Reviews Not Found

Valued by Individuals