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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
geisla_melo
New Member

Total Column doesn't match

Hi everyone!

I have a monthly value, and I need a measure that shows the actual monthly value less the last month value.
Except in january, cause it has to be the actual monthly value (I can't consider the past year value). When it gets to a month with 0, I can't do the subtraction to not have negative value.

I have this result, except for the totals, that keep making this substraction, showing a total 0 (zero).

This is how it looks like, I need the last column showing the total 51.117:

geisla_melo_0-1666731586083.png

 

These are my measures:
CH Mês Anterior: 

CALCULATE(SUM(CH Original), DATEADD(Periodo[Data], -1, MONTH), Periodo[Ano] = SELECTEDVALUE(Periodo[Ano]))

-------
CH Original Menos Mês Anterior:

CALCULATE(sumx(CargaHorariaAluno, CargaHorariaAluno[CH Original])) -
CALCULATE(SUMX(CargaHorariaAluno, CargaHorariaAluno[CH Original]), DATEADD(Periodo[Data], -1, MONTH), Periodo[Ano] = SELECTEDVALUE(Periodo[Ano]))

-------- 
CH Original Menos Mês Anterior Sem Negativo:

VAR UltimoMes = CALCULATE(Max(Periodo[Mês]),
FILTER(CargaHorariaAluno, CargaHorariaAluno[CH Original] > 0))

return
CALCULATE(sumx(CargaHorariaAluno, CargaHorariaAluno[CH Original])) -
CALCULATE(SUMX(CargaHorariaAluno, CargaHorariaAluno[CH Original]), DATEADD(Periodo[Data], -1, MONTH), Periodo[Ano] = SELECTEDVALUE(Periodo[Ano]), Periodo[Mês] <= UltimoMes)

------
I've trying a couple things using SUMX, but nothing is working.

Thanks in advance!
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @geisla_melo ,

 

As far as I know, this is a common problem with Power BI measure, the value of the total row is not calculated correctly because of the context and the calculation logic in the measure, you can try to create a new measure and use the Sumx() function to calculate the correct total value by defining a virtual table, for your current measure you can For your current measure you can try to create a new measure similar to this one and replace the corresponding measure in visual to achieve the requirement.

 

CH Mês Anterior1=
Var _table=Summarize(CargaHorariaAluno,[Mês], "1",[CH Mês Anterior])
return
If(Hasonevalue(CargaHorariaAluno[Mês]), [CH Mês Anterior], Sumx(_table,[1])

You can try a similar measure logic approach to achieve the correct display of the total column, if not, please refer to this blog that explains the same problem and solution.

Fixing Incorrect Totals Using DAX Measures In Power BI | Enterprise DNA

 

Best Regards,

Neeko Tang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. 

 

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @geisla_melo ,

 

As far as I know, this is a common problem with Power BI measure, the value of the total row is not calculated correctly because of the context and the calculation logic in the measure, you can try to create a new measure and use the Sumx() function to calculate the correct total value by defining a virtual table, for your current measure you can For your current measure you can try to create a new measure similar to this one and replace the corresponding measure in visual to achieve the requirement.

 

CH Mês Anterior1=
Var _table=Summarize(CargaHorariaAluno,[Mês], "1",[CH Mês Anterior])
return
If(Hasonevalue(CargaHorariaAluno[Mês]), [CH Mês Anterior], Sumx(_table,[1])

You can try a similar measure logic approach to achieve the correct display of the total column, if not, please refer to this blog that explains the same problem and solution.

Fixing Incorrect Totals Using DAX Measures In Power BI | Enterprise DNA

 

Best Regards,

Neeko Tang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. 

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.