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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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