Select Page

# VIDEO: How to Use SumX Function in DAX

by | Jul 21, 2020 | Video

When people first start with Power BI, they are often confused about the two functions in DAX  – SUM and SUMX. Both functions are doing the aggregation and it may be hard to see the difference between the two.

In this article, we take a look at the SUMX function and learn the difference between the two key aggregation functions in DAX.

First, let’s start with SUM. This is a basic sum function, similar to one in Excel. For example, if you would like to calculate the sum of all sales transactions in a store within a day, you will use the SUM function.

### SUMX Function

SUMX is an iteration function in DAX that does a row-by-row calculation based on a given expression or equation. The function considers each row in a table and if it fits the set parameter the function applies the calculation. In other words, SUMX is an iterator function, because it iterates through all the rows in a table and calculates the expression for every single row.

The function SUMX has two parameters – a table and expression. The table parameter references a named table in a data model, while the expression completes a specified calculation row by row.

Let’s take a look at the example from the video:

Sales = SUMX (SalesTable, SalesTable[Price] * SalesTable [Quantity] )

The easy way to understand this function is to think of it as a two-step process. The first step multiplies each row of the column [Price] by a corresponding row in the column [Quantity]. Then it temporarily stores the preliminary results in the backend memory.

As the second step, the function sums up the preliminary results, giving us a total.

Watch our short tutorial with a clear example to understand the power of the SUMX function.

## Tags:

DAX | Power BI | video
{"ft_lang_label":"__label__en","ft_lang_prob":0.8523778,"math_prob":0.9805177,"size":1695,"snap":"2023-40-2023-50","text_gpt3_token_len":358,"char_repetition_ratio":0.14370196,"word_repetition_ratio":0.006802721,"special_character_ratio":0.20353982,"punctuation_ratio":0.08841463,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9977969,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-09-28T18:42:05Z\",\"WARC-Record-ID\":\"<urn:uuid:cd09807f-675b-41c3-a6b8-64a2c31a8b33>\",\"Content-Length\":\"142407\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:60abc50c-4dbf-4b28-8029-19e992b0cef1>\",\"WARC-Concurrent-To\":\"<urn:uuid:6de578a3-a4f2-4672-909a-7bec631148f9>\",\"WARC-IP-Address\":\"194.1.147.7\",\"WARC-Target-URI\":\"https://centida.com/blog/video/video-dax-sumx-function/\",\"WARC-Payload-Digest\":\"sha1:2LCRLKDSTRJG5IGF35QUQXGGEJKRVYVW\",\"WARC-Block-Digest\":\"sha1:KAPJ4URDPUBCRCFGEEHB643HWVFVADVI\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-40/CC-MAIN-2023-40_segments_1695233510427.16_warc_CC-MAIN-20230928162907-20230928192907-00030.warc.gz\"}"}