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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
telesforo1969
Resolver I
Resolver I

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
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

Top Kudoed Authors