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
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
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.