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
Vilmar
Resolver I
Resolver I

Soma dos Quadrados (SUMX)

Ola
Por que tem diferença no total das duas fórmulas da SUMX, sendo que as duas são praticamente iguais?


Valor = SOMA ( Tabela[Venda]
 
Correto = SUMX ( Tabela;[ Valor]^2 )
Errado = SUMX ( Tabela; SUM( Tabela[Venda] ^ 2 )

 

 

Sem título.png

1 ACCEPTED SOLUTION
TomMartens
Super User
Super User

Hey,

 

this is because of the following effects

  • implicit filters applied by row/column headers and axis values, in your example an implicit filter is created by the value from column Produto
  • the context transition (row context is transformed into filter context whenever a measure is used
  • the absence of an implicit filter in the total line

My assumption about the content of your table Tabely: 3 rows

The value from column Errado in the total line is the result of the following calculation:

Three iterations, for each iteration the value for SUM(...[Venda]) is 12, as there is no context transition (explicitly by using the formula CALCULATE(...) or implicitly by referencing a measure); 12^2 equals 144 times 3 (three iterations) equals 432.

 

This is happening in the total line of the column Correto:

Once again 3 iterations, each time the measure [Valor] is referenced, referencing a measure also means that a context transition is transformed, the row context (SUMX is an iterator function) is transformed into a filter context. Product AA becomes a filter, BB becomes a filter, CC ...

For this reason the SUM of these iterations producing the result of 56: 2^2 (valor filtered by AA) + 4^2 (valor filtered by BB) + 6^2 (valor filtered by CC) 

 

Please allow me to direct your attention to this blog post: https://www.minceddata.info/2020/03/04/dax-universal-truths/

 

Hopefully, this explains what is happening.

 

Kind regards, and happy holidays

Tom

 

stay safe, stay healthy 

 



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

View solution in original post

4 REPLIES 4
TomMartens
Super User
Super User

Hey,

 

this is because of the following effects

  • implicit filters applied by row/column headers and axis values, in your example an implicit filter is created by the value from column Produto
  • the context transition (row context is transformed into filter context whenever a measure is used
  • the absence of an implicit filter in the total line

My assumption about the content of your table Tabely: 3 rows

The value from column Errado in the total line is the result of the following calculation:

Three iterations, for each iteration the value for SUM(...[Venda]) is 12, as there is no context transition (explicitly by using the formula CALCULATE(...) or implicitly by referencing a measure); 12^2 equals 144 times 3 (three iterations) equals 432.

 

This is happening in the total line of the column Correto:

Once again 3 iterations, each time the measure [Valor] is referenced, referencing a measure also means that a context transition is transformed, the row context (SUMX is an iterator function) is transformed into a filter context. Product AA becomes a filter, BB becomes a filter, CC ...

For this reason the SUM of these iterations producing the result of 56: 2^2 (valor filtered by AA) + 4^2 (valor filtered by BB) + 6^2 (valor filtered by CC) 

 

Please allow me to direct your attention to this blog post: https://www.minceddata.info/2020/03/04/dax-universal-truths/

 

Hopefully, this explains what is happening.

 

Kind regards, and happy holidays

Tom

 

stay safe, stay healthy 

 



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

@TomMartens Well explained my friend. Keep it up!! 💪



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

parry2k
Super User
Super User

@Vilmar I don't know spanish but here is how you will do it , add as a measure

 

Errado = SUMX ( Tabela, CALCULATE( SUM ( Tablea[Venda] ) ^ 2 ) )

 

Would appreciate Kudos 🙂 if my solution helped.Ask anything Power BI. Book appointment for a free consultancy at https://www.perytus.com 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Greg_Deckler
Super User
Super User

Isso parece um problema total de medidas. Muito comum. Veja meu post sobre isso aqui: https://community.powerbi.com/t5/DAX-Commands-and-Tips/Dealing-with-Measure-Totals/td-p/63376

Além disso, esta medida rápida, totais de medida, a palavra final deve obter-lhe o que você precisa:
https://community.powerbi.com/t5/Quick-Measures-Gallery/Measure-Totals-The-Final-Word/m-p/547907 desculpas pelo meu português, vem do Bing.

 

No entanto, no seu caso, eu acho que você está esquartejando seus números e, em seguida, resumir-los em sua segunda fórmula.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.