Forum Discussion

mizaskun's avatar
mizaskun
Icon for Helper II rankHelper II
5 years ago

DAX subtotal sum

Good afternoon,

 

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

 

I have the following measure:

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:

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

 

Thank you so much!

 

 

1 Reply

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