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

View all the Fabric Data Days sessions on demand. View schedule

Reply
mryoan04
Frequent Visitor

Return text from different column based on criteria

Hi, experts, need your help here.
I have below table. I want to fill the last two columns that evaluate the product condition based on "Is Scrapped" and "Scrap Reason" from Transaction = Work Order.
So for example, if Product A has "Y" on WO transaction, i would like to return "Y" as well for every invoices rows of Type A in column "Is Scraped on Invoice". The same with column "Scrap Reason on Invoice" (if Scrap Reason column is not blank, I would have that value on every invoice rows of Type A).

 

ProductTransactionDateIs ScrapedScrap ReasonColumn Wanted (Is Scraped on Invoice)Column Wanted (Scrap Reason on Invoice)
AInvoice7/1/2024  YDBR
AInvoice7/3/2024  YDBR
AWO7/2/2024    
AWO7/4/2024YDBR  
BInvoice8/1/2024  YBad Quality
BInvoice8/2/2024  YBad Quality
BInvoice8/3/2024  YBad Quality
BWO8/4/2024YBad Quality  

 

Thank you very much for your help!!

 

 

1 ACCEPTED SOLUTION
rajendraongole1
Super User
Super User

Hi @mryoan04 - you can create a calculated column to fill the "Is Scraped on Invoice" column based on the "WO" transactions as:

 

Is Scraped on Invoice =
VAR CurrentProduct = 'Workforce'[Product]
VAR IsScrappedWO =
CALCULATE(
MAX('Workforce'[Is Scraped]),
FILTER(
'Workforce',
'Workforce'[Product] = CurrentProduct &&
'Workforce'[Transaction] = "WO" &&
'Workforce'[Is Scraped] = "Y"
)
)
RETURN
IF(
'Workforce'[Transaction] = "Invoice" &&
NOT ISBLANK(IsScrappedWO),
IsScrappedWO,
BLANK()
)

 

To fill the "Scrap Reason on Invoice" column based on the "Work Order" transactions

Scrap Reason on Invoice =
VAR CurrentProduct = 'Workforce'[Product]
VAR ScrapReasonWO =
CALCULATE(
MAX('Workforce'[Scrap Reason]),
FILTER(
'Workforce',
'Workforce'[Product] = CurrentProduct &&
'Workforce'[Transaction] = "WO" &&
NOT ISBLANK('Workforce'[Scrap Reason])
)
)
RETURN
IF(
'Workforce'[Transaction] = "Invoice" &&
NOT ISBLANK(ScrapReasonWO),
ScrapReasonWO,
BLANK()
)

 

this works. please check





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





View solution in original post

2 REPLIES 2
rajendraongole1
Super User
Super User

Hi @mryoan04 - you can create a calculated column to fill the "Is Scraped on Invoice" column based on the "WO" transactions as:

 

Is Scraped on Invoice =
VAR CurrentProduct = 'Workforce'[Product]
VAR IsScrappedWO =
CALCULATE(
MAX('Workforce'[Is Scraped]),
FILTER(
'Workforce',
'Workforce'[Product] = CurrentProduct &&
'Workforce'[Transaction] = "WO" &&
'Workforce'[Is Scraped] = "Y"
)
)
RETURN
IF(
'Workforce'[Transaction] = "Invoice" &&
NOT ISBLANK(IsScrappedWO),
IsScrappedWO,
BLANK()
)

 

To fill the "Scrap Reason on Invoice" column based on the "Work Order" transactions

Scrap Reason on Invoice =
VAR CurrentProduct = 'Workforce'[Product]
VAR ScrapReasonWO =
CALCULATE(
MAX('Workforce'[Scrap Reason]),
FILTER(
'Workforce',
'Workforce'[Product] = CurrentProduct &&
'Workforce'[Transaction] = "WO" &&
NOT ISBLANK('Workforce'[Scrap Reason])
)
)
RETURN
IF(
'Workforce'[Transaction] = "Invoice" &&
NOT ISBLANK(ScrapReasonWO),
ScrapReasonWO,
BLANK()
)

 

this works. please check





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Thank you! It works!

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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
Top Kudoed Authors