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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
timealan
New Member

Create a new column result from multiple rows

Hello,

 

I have a realtively simple data set. Purchase order / Purchase Order Line / OT.

 

"OT" is a previously added column that checks whether or not the receipts against the line are "ONTIME" or "LATE"...

 

I would like to create a two new columns:

 

"LINE-OT" that tells me whether the PO LINE as a whole is either "ONTIME" (ie all "OT" against that line "ONTIME") or "LATE" (ie at least one "OT" against the PO line is "Late")

 

"PO-OT" that tells me whether all the POLINE on that PO are either "ONTIME" (ie all "LINEOT" are "ONTIME") or "LATE" (ie at least on "LINEOT" relating to the PO is "LATE")

 

Capture.JPG

Whats the best approach to this? I can add reasonably complicated condtional columns, but am unsure how to base the condition on a subset of data.

 

Thanks

 

Simon

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@timealan , Both as new columns

 

PO Status =
var _late = countx(filter(table, [purchase_order] =earlier([purchase_order]) && [OT] = "LATE"),[purchase_order])+0
return
if(_late >0 , "LATE" , "ONTIME")


PO_LINE Status =
var _late = countx(filter(table, [purchase_order] =earlier([purchase_order]) && [PO_LINE] =earlier([PO_LINE]) && [OT] = "LATE"),[purchase_order])+0
return
if(_late >0 , "LATE" , "ONTIME")

View solution in original post

2 REPLIES 2
timealan
New Member

Capture2.JPG

Thank you very much. I tip my hat to you. 

amitchandak
Super User
Super User

@timealan , Both as new columns

 

PO Status =
var _late = countx(filter(table, [purchase_order] =earlier([purchase_order]) && [OT] = "LATE"),[purchase_order])+0
return
if(_late >0 , "LATE" , "ONTIME")


PO_LINE Status =
var _late = countx(filter(table, [purchase_order] =earlier([purchase_order]) && [PO_LINE] =earlier([PO_LINE]) && [OT] = "LATE"),[purchase_order])+0
return
if(_late >0 , "LATE" , "ONTIME")

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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