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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
mizaskun
Helper II
Helper II

DAX subtotal sum

Good afternoon,

 

I am having problems trying to come up with a subtotal.

 

I have the following measure:

mizaskun_0-1625144930873.png

M_IMPACTO_ECONOMICO = calculate([M_IMPACTO_FINAL], VALORACIONES[IMPACT_CAT] = "001")
M_IMPACTO_FINAL = if(firstnonblank(IMPACTO[IMPACTO],1) = "PONDERADO",[M_IMPACTO_PONDERADO],[M_IMPACTO_SIMPLE])
M_IMPACTO_PONDERADO = if(isinscope(PESOS[REGION]), [M_IMPACTO]*[M_PERCENT], sumx(values(PESOS[REGION]), [M_IMPACTO]*[M_PERCENT]))
M_IMPACTO = VAR valoraciones_count = addcolumns(valoraciones, "@Count", countrows(relatedTable(ZRIESGOS_AMPLIADA))) VAR _num = sumx(valoraciones_count, VALORACIONES[QUAL_IMPACT]*[@Count]) VAR _den = sumx(valoraciones_count, [@Count]) VAR _res = divide(_num, _den) return _res
 
The problem I am having is that it does an operation that I cannot understand in the subtotal of a table:
mizaskun_1-1625145052086.png

How could I get the sum of the values? It should be 12,48.

 

Thank you so much!

 

 

1 REPLY 1
daxer-almighty
Solution Sage
Solution Sage

Yeah... Writing DAX the way you do... is a sure way to not understand what it does. DAX which is not correctly formatted is not DAX. Rules for DAX Code Formatting - SQLBI


By the way, using nested IF's is not elegant. There's a better way: SWITCH.

 

After two days nobody has even tried to reply to your post. Guess why.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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