Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
Yossarian
Helper I
Helper I

totals on SUMX - how to keep row context

Hi,

 

I've been through this forum and found some posts that broach the subject but do not quite match my requirements.

So, my problem is simple to explain. I need SUMX to actually sum the values in the column.

The picke resides in the following: the measure without SUMX computes to 0 (as it should). On the other hand, the measure with SUMX declaring VARS computes to a very large number because there are implicit filters in the rows that are not being considered when computing the total. And the measure with SUMX not declaring VARS does not compute correctly row wise because the row context limits inherently its scope.

Let me give an example:

Yossarian_0-1662459117655.png

 

The measure in question is the Monetized Qt Correction Var and it is the product of price and the difference of quantities. As the Qt correction only redistributes the total quantity by each line, the total quantities are exactly the same. I need my measure to sum up to -34.698 (the points are the thousands separators).

Let me paste the 3 measures above and the model (very basic):

Yossarian_1-1662459571369.png

 

Yossarian_3-1662459716625.png

Yossarian_4-1662459767621.png

 

Yossarian_5-1662459812774.png

 

How should I go about this?

Thanks!

 

 

1 ACCEPTED SOLUTION

Hi @Yossarian , Yes, sorry I didn't spot that one. Have you tried summarize. Sorry now I'm only firing bits out because I don't see your underlying model.

 

Sumx(Summarize(Buyer, Product, "Measure",[Measure]),[Measure])

 

 

View solution in original post

5 REPLIES 5
davehus
Memorable Member
Memorable Member

Hi @Yossarian ,

Try this and see if it works.

 

SUMX(FIRSTNONBLANK('TBL BUYERPROD'[BUYER],1),[Monetised Qt Correction Var (Sumx Meas vers)])

 

Hope this helps,

 

Did I help you today? Please accept my solution and hit the Kudos button.

 

Hi @davehus ,

 

It seems it is not the solution:

Yossarian_0-1662480052827.png

 

Anyway, why restricting the table (on SUMX) to only the first buyer (if I am reading correctly)?
Thanks!

Hi @Yossarian , Yes, sorry I didn't spot that one. Have you tried summarize. Sorry now I'm only firing bits out because I don't see your underlying model.

 

Sumx(Summarize(Buyer, Product, "Measure",[Measure]),[Measure])

 

 

Hi @davehus ,

 

Just a quick follow up question if you don't mind.
For me, conceptually, the correct approach would be to SUM the column of the summarized table. Why does SUMX on your solution use the calculated values of the inner measure? Shouldn't it just iterate on the summarized table and calculate the measure again - leading to the same results as before?

 

Thanks again!

Hi @davehus ,

 

Yes, I have tried summarize but with addcolumns instead. I can't really tell how many variations I have tried to no avail.

 

However, your proposal works for the total! 👌 It works with 2 of the measures (the SUMX VAR version and the no SUMX version). The underlying model is the one I posted, there isn't really anything else (the buyerprod table is used to slice data basically and is one-to-many to sales table).

Yossarian_0-1662482296648.png

 

 

If it is not possible to consider a measure displaying correctly both rows and total, I will proceed with the "IF workaround" and mark your reply as the solution.

Lifesaviour post, really!

Thanks.

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.