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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
HCK21
New Member

Calculated fields using data from different table

HI,

 

I have two tables; one with customer data and one with order data.

I would like to be able to add a column (like the one in red) to the customer table to show whether all orders are fulfilled for that custom, based on the following rules:

  • If a customer doesn't appear in the order table at all then "No orders"
  • If one or more orders for that customerid have a row that says "no" in fulfilled column, then All Orders Fulfilled should say "Unfulfilled orders"
  • If all orders in order table say for that customerID say "Yes", then "All orders Fulfilled" 
CustomerIdCustomerNameAll orders fulfilled
1StellaNo orders
2JoanAll orders fulfilled
3MargeUnfulfilled orders

 

OrderIDCustomerIDOrderFulfilled
12PantsYes
23PantsYes
34ShoesNo
42ShoesYes
52SocksYes
63ShoesNo
76PantsNo

 

1 ACCEPTED SOLUTION
parry2k
Super User
Super User

Sorry there is a typo, it suppose to be FIlTER not FILTERS



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

5 REPLIES 5
HCK21
New Member

Thanks @parry2k - this works like a charm

Ashish_Mathur
Super User
Super User

Hi,

This calculated column formula works

Column = if(CALCULATE(COUNTROWS('Table'),FILTER('Table','Table'[CustomerID]=EARLIER(Data[CustomerId])))=BLANK(),"No orders",if(CALCULATE(COUNTROWS('Table'),FILTER('Table','Table'[CustomerID]=EARLIER(Data[CustomerId])&&'Table'[Fulfilled]="Yes"))=CALCULATE(COUNTROWS('Table'),FILTER('Table','Table'[CustomerID]=EARLIER(Data[CustomerId]))),"All orders fulfilled","Not fulfilled"))

Hope this helps.

Ashish_Mathur_0-1694921400549.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
parry2k
Super User
Super User

Sorry there is a typo, it suppose to be FIlTER not FILTERS



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

HCK21
New Member

HI @parry2k 

 

Thanks for the speedy response. I've change the table/column names in your suggestion to reflect my column names etc, but I'm getting an error on this part of the statement. PowerBI error says "Parameter is not the correct type" and suggests this part of the arguement should be a table. I think i'm probably missing something obvious.

FILTERS ( __Orders, OrderTable[Fullfilled Column] = "No"  )

 

parry2k
Super User
Super User

@HCK21 try following calculated column in the customer table:

 

All Orders Fulfilled = 
VAR __Orders = RELATEDTABLE ( OrderTable )
VAR __CountNo = COUNTROWS ( FILTERS ( __Orders, OrderTable[Fullfilled Column] = "No"  ) )
RETURN
SWITCH ( TRUE (),
   ISEMPTY ( __Orders ), "No Orders",
   NOT ISBLANK ( __CountNo ), "Unfulfilled Orders",
   "All orders fulfilled"
)


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

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!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Feb2025 NL Carousel

Fabric Community Update - February 2025

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