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
AntonioCarl
Helper I
Helper I

Iteration over iteration in calculated column

Hi there, 

 

I've got table like below. 

I need to create calculated column with something I've got problem with.

For each ORDER_ID I want to sum over iteration over DELIVERY_NOTE_ID where I calculate average of  ORDER_QUANTITY. 
Basically, in example, I want to go through ORDER_ID = 131371 and iterate over DELIVERY_NOTE_ID = 974441 and calculate average of ORDER_QUANTITY. For DELIVERY_NOTE_ID = 974441 it should return 2 and through DELIVERY_NOTE_ID = 974440 I should get 4. Now I come back to  ORDER_ID = 131371 and sum those values to get 6. 

It's easy to do it in measure but I'm stuck in calculated column. 

SUMX(
    VALUES( Table[DELIVERY_NOTE_ID] ),
    CALCULATE( AVERAGE(Table[ORDER_QUANTITY] ) ) 
)
 
ORDER_IDDELIVERY_NOTE_IDORDER_QUANTITYDELIVERY_NOTE_QUANTITY
13137197444121
13137197444121
13137197444044
1 ACCEPTED SOLUTION
Daniel29195
Super User
Super User

@AntonioCarl 

 

output : 

Daniel29195_0-1707383974826.png

 

 

calcualtion : 

 

Column = 
var oi =  tbl3[ORDER_ID]
var dni  = tbl3[DELIVERY_NOTE_ID]
var ds = 
FILTER(
    tbl3,
    tbl3[ORDER_ID]= oi && tbl3[DELIVERY_NOTE_ID]= dni
)

var res = 
SUMX(
    ds,
    tbl3[ORDER_QUANTITY]
)/
COUNTROWS(ds)
return res

 

 

 

 

let me know if this works for you . 

 

 

 

 

 

If my answer helped sort things out for you, i would appreciate a thumbs up 👍 and mark it as the solution
It makes a difference and might help someone else too. Thanks for spreading the good vibes! 🤠

 

View solution in original post

1 REPLY 1
Daniel29195
Super User
Super User

@AntonioCarl 

 

output : 

Daniel29195_0-1707383974826.png

 

 

calcualtion : 

 

Column = 
var oi =  tbl3[ORDER_ID]
var dni  = tbl3[DELIVERY_NOTE_ID]
var ds = 
FILTER(
    tbl3,
    tbl3[ORDER_ID]= oi && tbl3[DELIVERY_NOTE_ID]= dni
)

var res = 
SUMX(
    ds,
    tbl3[ORDER_QUANTITY]
)/
COUNTROWS(ds)
return res

 

 

 

 

let me know if this works for you . 

 

 

 

 

 

If my answer helped sort things out for you, i would appreciate a thumbs up 👍 and mark it as the solution
It makes a difference and might help someone else too. Thanks for spreading the good vibes! 🤠

 

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors