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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
gcz
New Member

Total is wrong

The total is wrong, I really dont know why.

 

Print: imgur.com/a/5mbub

 

---------

Estoque Disponível VAR e IF =


VAR x = SUMX(SUMMARIZE(ESTOQUE;ESTOQUE[PRODUTO];ESTOQUE[SALDO]);ESTOQUE[SALDO])      // SALDO


VAR y = CALCULATE([Total Pendência];ALL(CALENDARIO[Data]))                                                             // PENDENCIA


VAR z = ALLSELECTED(CALENDARIO[Data])

 

 

RETURN CALCULATE(IF(x = 0;BLANK();IF(x - y < 0;BLANK();x - y))
;z)

---------

1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hi @gcz,

 

You want the total to be the sum of the several lines correct?

 

So you need to do the SUMX of the Calculate function you have on your Return, like you have the formula setup you are making the calculations for the total rows and then using the IF, because the measure is based on context.

 

Regards,

MFelix

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

3 REPLIES 3
MFelix
Super User
Super User

Hi @gcz,

 

You want the total to be the sum of the several lines correct?

 

So you need to do the SUMX of the Calculate function you have on your Return, like you have the formula setup you are making the calculations for the total rows and then using the IF, because the measure is based on context.

 

Regards,

MFelix

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



I created this code: 

 

Estoque Disponível VAR e IF by Felipe =


VAR x = SUMX(SUMMARIZE(ESTOQUE;ESTOQUE[PRODUTO];ESTOQUE[SALDO]);ESTOQUE[SALDO]) // SALDO
VAR y = CALCULATE([Total Pendência];ALL(CALENDARIO[Data])) // PENDENCIA
VAR z = ALLSELECTED(CALENDARIO[Data])

 

RETURN SUMX(VALUES(PRODUTOS[PRO_CODPRO]);CALCULATE(IF(x = 0;BLANK();IF(x - y < 0;BLANK();x - y));z))

 

______________________________________________________________________________________________________________________

 

 

Still the same error, total is different.

 

Print: imgur.com/a/pj5HY

 

 

And I created a code to give me the correct total: 

 

TOTAL Estoque Disponível VAR e IF = SUMX(VALUES(PRODUTOS[PRO_CODPRO]);ESTOQUE[Estoque Disponível VAR e IF])

 

 

 

But which table I need to use in the SUMX?

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors