How to Use SUMX Power BI Function and How is it Different from SUM?

on BI Tool, Business Intelligence, Data Analytics, Data Integration, Data Visualization, Power BI, Power BI Dashboards, Tutorials • March 11th, 2022 • Write for Hevo

SUMX POWER BI FEATURE IMAGE

Power BI is a rapidly growing Business Intelligence (BI) tool and a Data Visualization software developed by Microsoft to transform the way Data Analytics is used by organizations to solve business problems. Power BI makes working with data really easy with real-time high-level analytics, extensive modeling, and custom development. However, when using Microsoft Power BI, you’ll frequently discover that you have to work around various functions to make the most of business data. This blog will take you through one such classical and important function, SUMX Power BI.

Data Analysis Expressions (DAX) is a collection of functions, operators, and constants used to create formulae and expressions in Power BI. DAX SUMX is one such inbuilt mathematical DAX function in Power BI that returns the sum of expression from a table. SUMX Power BI is an iteration function that works on a row by row calculation as per the given expression. But before getting started with SUMX Power BI, let’s discuss this robust BI platform in brief.

Table of Contents

What is Power BI?

SUMX Power BI: Power BI
Image Source: www.pngitem.com

Power BI is a Business Intelligence (BI) tool and a Data Visualization platform offered by Microsoft that allows organizations to analyze business data and generate reports. Power BI comes with a set of built-in tools, apps, and connectors that can deeply delve and work with data to provide actionable insights, immersive visuals, and interactive reports.

Power BI is actually self-service Business Intelligence which means that you can easily aggregate data, analyze data, visualize data, and produce some fantastic-looking visual reports. Power BI lets you pull data in from multiple sources such as Oracle, SAP, or a Data Warehouse of your choice. It can handle everything from your simple Excel file all the way to massive amounts of data. You can leverage the Power BI Chart, Graphs, KPIs, Reports, and Dashboards to analyze the data and get interactive insights.

Key Features of Power BI

Power BI has proven to be a reliable and user-friendly Data Analysis and Visualization tool. Let’s discover some of its key features responsible for its immense popularity.

  • Easy Integrations: Power BI offers integrations with multiple connectors that allow users to pull in data from various data sources.
  • AI Support: Power BI allows users to deploy Artificial Intelligence (AI) techniques such as Image Recognition and Text Analytics to prepare data, develop Machine Learning models, and quickly extract actionable insights from structured and unstructured data.
  • Report Sharing: Power BI is built for developing security that allows teams to share access in a very controlled manner. Users can easily share their reports with other team members without compromising data security.
  • Real-Time Dashboards: Power BI has the capability to display real-time data and visuals in any report or dashboard. Power BI dashboards update in real-time allowing users to instantly solve issues and uncover opportunities.
  • Customized Visualization: Power BI offers high customizability and allows users to leverage its custom visualization library to create visualizations as per their needs. In addition to that, analysts can also generate highly customizable visuals for their next Power BI report by using open-source data-viz modules from R and Python.

Simplify Power BI Data Analysis with Hevo’s No-code Data Pipeline

HevoData is a No-code Data Pipeline that offers a fully managed solution to set up data integration from 100+ Data Sources (including 30+ Free Data Sources) and will let you directly load data to a Data Warehouse to be visualized in a BI tool such as Power BI. It will automate your data flow in minutes without writing any line of code. Its fault-tolerant architecture makes sure that your data is secure and consistent. Hevo provides you with a truly efficient and fully automated solution to manage data in real-time and always have analysis-ready data.

Get started with hevo for free

Let’s look at some of the salient features of Hevo:

  • Fully Managed: It requires no management and maintenance as Hevo is a fully automated platform.
  • Data Transformation: It provides a simple interface to perfect, modify, and enrich the data you want to transfer.
  • Real-Time: Hevo offers real-time data migration. So, your data is always ready for analysis.
  • Schema Management: Hevo can automatically detect the schema of the incoming data and map it to the destination schema.
  • Scalable Infrastructure: Hevo has in-built integrations for 100’s of sources that can help you scale your data infrastructure as required.
  • Live Monitoring: Advanced monitoring gives you a one-stop view to watch all the activities that occur within Data Pipelines.
  • Live Support: Hevo team is available round the clock to extend exceptional support to its customers through chat, email, and support calls.
Sign up here for a 14-day free trial!

What is SUMX Power BI Function?

The Power BI Data Analysis Expressions (DAX) comprises over 200 functions, operators, and constants that provide immense flexibility in Data Analysis tasks. SUMX Power BI is a DAX iterator function that forms the fundamental block for tabular models. Being an iterator function, DAX SUMX iterates through every row of a specified table and facilitates the sum of products. This means that the product of the corresponding field values is first performed for each row and the values are then added.

Iterator functions perform row-by-row calculations by considering each row at a time and applying the calculation. Other iterator functions include COUNTX, RANKX, PRODUCTX, etc.

Syntax

A typical SUMX Power BI function looks like this:

SUMX (<Table>, <Expression>)

Let’s break this down and try to understand the 2 parameters.

  • Table: This specifies the table name to which the DAX SUMX function is applied. The steps or iterations will be carried out on the rows of this table.
  • Expression: This is the Expression or Equation that needs to be evaluated row-wise.

A SCALAR return value of any type is returned as the result of the sum.

Example

Sales Amount = SUMX ( Sales, Sales[Quantity] * Sales[Net Price] )

SUMX will iterate through a sample table “Sales” specified in the first parameter, row by row, and perform the calculation (Quantity*Net Price) specified in the second parameter. After evaluating the calculation for every row in the specified table, it’ll add up all the values.

DEFINE
MEASURE Sales[Sales Amount] = SUMX ( Sales, Sales[Quantity] * Sales[Net Price] )
EVALUATE
SUMMARIZECOLUMNS (
    'Product'[Color],
    "Sales Amount", [Sales Amount]
)

The above query will return the following output.

SUMX Power BI: Example Output
Image Source: www.dax.do

How To Use SUMX in Power BI?

Applying the SUMX Power BI function is very much straightforward. For the purpose of this demonstration, a sample “Sales_Table” is considered. The dataset contains data pertaining to different cities, the cost price of a product, and the number of units sold. Using the SUMX DAX function, the total sales value can be calculated. To do so, follow the below-mentioned steps.

Here’s the sample dataset.

SUMX Power BI: Dataset
Image Source: www.wallstreetmojo.com

As you can observe, the table contains 3 columns: City, Price, and Units. You can now upload this dataset to Power BI.

  • To do so, go to the “Home” menu and click on the “Get Data” tab.
  • Since our data is in Excel, select the “Excel” option.
SUMX Power BI: Get Data
Image Source: www.educba.com
  • Click on “Load” and name the table as “Sales_Table”.
SUMX Power BI: Sales_Table
Image Source: www.wallstreetmojo.com
  • To arrive at each row calculation, apply the SUMX Power BI function in “New Measure”. Right-click on the table and select “New Measure”.
SUMX Power BI: New Measure
Image Source: www.wallstreetmojo.com
  • Name this new measure as “Sales Value”.
SUMX Power BI: Sales Value
Image Source: www.wallstreetmojo.com
  • Open the SUMX function and provide the table name and the expression to be evaluated. The table name is “Sales_Table” and you need to multiply Units with Price to get the Sales Value.
  • Close the bracket and press “Enter” to get the result.
SUMX Power BI: Syntax
Image Source: www.wallstreetmojo.com
  • Now, to visualize the results, click on the “Report” tab and insert the “Table” visual in it from the visualization list.
SUMX Power BI: Report
Image Source: www.wallstreetmojo.com
  • Drag and drop the “City” and “Sale Value” fields under the “Values” tab to get the summary table.
SUMX Power BI: Visualization
Image Source: www.wallstreetmojo.com
  • This returns the Sales Value for each city as desired.
SUMX Power BI
Image Source: www.wallstreetmojo.com

How is SUMX Power BI Different From SUM Power BI?

Understanding the difference between SUM and SUMX Power BI functions can be a turning point for many Data Professionals. Learning how to leverage these functions appropriately can provide the opportunity to dive deeper into raw data to extract actionable insights with ease. Using them effectively will remove complexities from your Data Analysis and will unleash the full potential of your data. Though both the functions look similar, they’re much different.

Power BI comprises 2 basic Calculation Engines: Aggregator Engine and Iterator Engine. DAX SUM function belongs to the Aggregator Engine and it adds all the values in a single column to return the result. SUM considers a single column as a whole and returns a result. SUM and other aggregator functions are not capable of performing row-wise evaluations.

A typical SUM function looks like this:

SUM(<Column Name>)

Example: Total Units = SUM(Sales_Table[Units])

As discussed, the DAX SUM function considers a single column of data to add all the data in that column. So, the SUM function will add every single value in the “Units” column of Sales_Table to return the total number of units.

SUMX is an iterator function and takes a different approach. Unlike SUM, SUMX is capable of performing row-by-row calculations and iterates through every row of a specified table to complete the calculation. SUMX then adds all the row-wise results of the iterations of the given expression.

A typical SUMX function looks like this:

SUMX (<Table>, <Expression>)

Example: Sales_Table[Sales Value] = SUMX ( Sales_Table, Sales_Table[Units] * Sales_Table[Price] )

As discussed, the SUMX function will iterate through every row to perform the given calculation before adding the row-by-row values. So, the SUMX function will multiply the “Price” and “Units” from every single row and will then add the results to return the total sales amount in the “Sales Value” column.

When to Use Power BI SUMX?

You can use the SUMX function whenever there is a need for the row-by-row calculation. Hence, if your data is structured in a way that you will necessarily need to multiply values from 2 columns one row at a time in order to get the desired result, you simply must use the SUMX Power BI function.

SUMX can operate over a single column as well, so, you could, in theory, use SUMX as a simple aggregation function to add all the values in a column. However, it is not recommended to use SUMX as an aggregator due to its iterative nature. SUMX uses more resources than a SUM function and might affect the performance of your dashboard negatively.

When to Use Power BI SUM?

SUM should be used whenever it is just a simple calculation across a single column and row-wise execution is not required. Hence, if your data is structured in a way that it contains only a single column of values, then you can use SUM to add up the values. The DAX SUM function operates over a single column and hence there is no need for an iterator in a case where you are simply trying to calculate the sum of a column of data.

Conclusion

Power BI is Microsoft’s Business Intelligence tool used by Data Professionals all over the world to examine data from multiple sources and create attractive Charts, Dashboards, and Reports according to user-specified data. Making reports using the Power BI functionalities of data importing, transforming, and visualizing is a smooth experience. However, one must be familiar with important DAX functions such as SUMX Power BI to get the most out of raw data.

This blog introduced you to Power BI and took you through various aspects of the SUMX Power BI function. The article also differentiates between Power BI SUM and SUMX functions before concluding. Power BI makes Business Analysis more efficient through intuitive, interactive, and easy-to-use services. Moreover, analyzing and visualizing your data by loading it from a Data Warehouse to Power BI can be cumbersome. This is where Hevo comes in.

visit our website to explore hevo

Hevo Data with its strong integration with 100+ Sources & BI tools allows you to not only export data from sources & load data in the destinations, but also transform & enrich your data, & make it analysis-ready so that you can focus only on your key business needs and perform insightful analysis using BI tools such as Power BI.

Give Hevo Data a try and sign up for a 14-day free trial today. Hevo offers plans & pricing for different use cases and business needs, check them out!

Share your experience of understanding the SUMX Power BI function in the comments section below.

No-code Data Pipeline For Power BI