Sum() vs Sumx()

 Power BI SUM() vs SUMX()





This is the our sample data, which we'll use in our demo example.
if we want to find out Total Sales Amount, then we've to multiply with Qty*Price each row and then finally all that value would be summed up(Addition/Sum). The below snapshot explain that way.


This image is just for demo, in next step it's explained in Power BI window.

Now the data is already imported in Power BI window.



And here want to find out the Total Sales Amount,

So first approach we're using SUM() Function, so we already know that SUM() works on the column, means here SUM()  function can not works as each Item's Qty would be multiply with Price (Qty*Price) and then finally all the values would be summed up(addition/sum).
    It means if we want to use SUM() function then we need to add a Helper column (Qty*Price), and then SUM() function would be applied on that Helper Column. And these steps are explained below:

Adding a helper column.







And after the Helper column we're using Measure to get Sum of the Helper_Column in below step:




And now SUM_fn measure is ready to use, on Visual Page just take Card from visuals just drag already created measure SUM_fn on the Card.



And now it's the way to deal with SUM() FUNCTION , which is suitable to work with column only that can not directly do some operation and row and then finally sum up that can not.

Now let us see SUMX() FUNCTION, that can do firstly multiply in rows and then finally sum up them(addition/sum).



So just take a measure(for scaler value output) and put the formula for =SUMX(TABLE_NAME, EXPRESSION)
And finally output is in front of you just use a Card to see the value.

see the same video on youtube https://youtu.be/lrpvrUFYukU














Comments