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
telesforo1969
Helper V
Helper V

sum and division calculation for a matrix (in a single measure)

I need to calculate three sums and one division in a single step (Measure)  to create the array shown in the image.

Each month is also calculated (Precio = Costos / Consumos)

MatrizSuma y división.JPG

2 ACCEPTED SOLUTIONS
speedramps
Super User
Super User

Thanks for the exmaple picture!

 

Try this

 

Create some test data

speedramps_2-1749057789799.png

Create a DAX measure

Answer = 
var myvariable = SELECTEDVALUE(yourdata[Variable])
var x = CALCULATE(SUM(yourdata[Value]), yourdata[Variable] = "Costos")
var y = CALCULATE(SUM(yourdata[Value]), yourdata[Variable] = "Consumos")

RETURN
IF(myvariable = "Precio", 
DIVIDE(x , y),
SUM(yourdata[Value])
)

 

Draw your matrix 

speedramps_3-1749058635469.png

 

 

Please click at least thumbs up for me trying to help.

Then click [accept solution] if it works.

 

Or provide a better description with input data as table (not a picture)
and example output. 

 

You will get a quick and better answer with no misunderstandings if you provide clear examples

View solution in original post

Muchas gracias desde México. 
The arrays with the months are no problem. I'll take care of it. Thank you very much.

MatrizSuma y división 1.JPG

View solution in original post

5 REPLIES 5
speedramps
Super User
Super User

@telesforo1969 

I am glad my solution solved your problem.

 

Please click the thumbs-up and [accept solution] button. 

 

Thank you !

speedramps
Super User
Super User

Thanks for the exmaple picture!

 

Try this

 

Create some test data

speedramps_2-1749057789799.png

Create a DAX measure

Answer = 
var myvariable = SELECTEDVALUE(yourdata[Variable])
var x = CALCULATE(SUM(yourdata[Value]), yourdata[Variable] = "Costos")
var y = CALCULATE(SUM(yourdata[Value]), yourdata[Variable] = "Consumos")

RETURN
IF(myvariable = "Precio", 
DIVIDE(x , y),
SUM(yourdata[Value])
)

 

Draw your matrix 

speedramps_3-1749058635469.png

 

 

Please click at least thumbs up for me trying to help.

Then click [accept solution] if it works.

 

Or provide a better description with input data as table (not a picture)
and example output. 

 

You will get a quick and better answer with no misunderstandings if you provide clear examples

Muchas gracias desde México. 
The arrays with the months are no problem. I'll take care of it. Thank you very much.

MatrizSuma y división 1.JPG

ajaybabuinturi
Solution Sage
Solution Sage

Hi @telesforo1969,
Could ypu please provide the data how it's looking in Power BI and what type of visual are you going to used.

Thank you. It's a matrix, and I solved it with the proposed "speedramps" code.

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!

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