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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
lotus22
Helper III
Helper III

Add custom column with Lookup on the same table

Customer PartSupplier PartLine TypeTotalsExpected
     
CPart A Customer Demand12345Empty
CPart ASPartYSupplier Order5612345
CPart DSPartXSupplier Order56Empty
CPart B Customer Demand5869Empty
CPart ESPartNSupplier Order25Empty
CPart BSPartOSupplier Order665689

 

In Expected column, I would like to bring Totals from Customer Demand when the Customer Part Number matches  Customer Part No in the Supplier Order field.

 

Therefore, the lookup will be only based on Customer Part Number but the data will only  come from the Customer Demand row. it is more like of multi filter.

1 ACCEPTED SOLUTION

Hi, @lotus22 

"Type 2"  is a calculated column ,so it cannot be found in Power Query.

You can try create a calculated column as below:

Column = 
var a=CALCULATE(SUM('Table'[Totals]),ALLEXCEPT('Table','Table'[Customer Part]),'Table'[Type]="Customer Demand")
return  IF('Table'[Type]="Customer Demand",BLANK(),a)

91.png

 

 pbix attached

 

Best Regards,
Community Support Team _ Eason
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

5 REPLIES 5
camargos88
Community Champion
Community Champion

Hi @lotus22 ,

 

You can create a custom column like this:

if [Line Type] = "Supplier Order" then
let 
_customerPart = [Customer Part], 
_rows =  Table.SelectRows(#"Changed Type", each [Customer Part] = _customerPart and [Line Type] = "Customer Demand") 
in
if Table.IsEmpty(_rows) then null 
else _rows[Totals]{0}

else null

 

Capture.PNG



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

Proud to be a Super User!



error received

 

Expression.Error: The field 'Type2' of the record wasn't found.

Type2 is a calculated column

Hi, @lotus22 

"Type 2"  is a calculated column ,so it cannot be found in Power Query.

You can try create a calculated column as below:

Column = 
var a=CALCULATE(SUM('Table'[Totals]),ALLEXCEPT('Table','Table'[Customer Part]),'Table'[Type]="Customer Demand")
return  IF('Table'[Type]="Customer Demand",BLANK(),a)

91.png

 

 pbix attached

 

Best Regards,
Community Support Team _ Eason
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Thank you, but i see all "null" when I incorporate same formula. I have about 30 columns in my power query

 

if [Type2] = "Supplier Order" then
let
_customerPart = [CustomerPart],
_rows = Table.SelectRows(#"Changed Type", each [CustomerPart] = _customerPart and [Type2] = "Customer Demand")
in
if Table.IsEmpty(_rows) then null
else _rows[Totals]{0}

else null

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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