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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
FrederikB
Frequent Visitor

Get data from another table where condition is met

I have three tables:

 

Bookings

IDSome value
1a
2b
3c
4d

 

Invoices

IDTotalRevenueBookingID
1201
2201
3302
4302

 

Line items

IDBookingIDTitleValue
11Service fee30
21Transport fee20
31Price of product10
41Some other title40

 

I want to show the booking table and joining the values from the two other tables into the booking table.

 

I have tried to make a relationship by BookingID (and ID of the booking table), and then gotten some values like the service fee by

 

Service fee = calculate(sum('Line items'[Value]),'Line items'[data.invoices.lineItems.Title]="Service fee")

 

and equally for the other values.

 

But when showing values from the line items table in the booking table, the values are just flat out wrong. If I only show the values by themself (and applying a filter to only see values for bookingID=1), it works like charm.

 

So I thought a better solution would be to simply bring in the values from the two other two tables into the booking table to display them, but the problem is that it is a one-to-many relationship, so I can't do that. 

But I thought that maybe I can make a query to like (psuedo code below):

 

service fee = get 'Value' from line items table where 'Title' = 'Service fee'

 

Is it possible to do this, or would there be a better way to go arround this?

1 ACCEPTED SOLUTION
v-kkf-msft
Community Support
Community Support

Hi @FrederikB ,

 

According to my tests, your formula is able to calculate the summary values correctly. 

 

vkkfmsft_0-1643771653996.png

vkkfmsft_2-1643771707916.png

 

If you want to attach the underlying data, try merging the two tables in the Power Query Editor.

 

    vkkfmsft_6-1643771915968.png

vkkfmsft_7-1643771975097.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
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

2 REPLIES 2
v-kkf-msft
Community Support
Community Support

Hi @FrederikB ,

 

According to my tests, your formula is able to calculate the summary values correctly. 

 

vkkfmsft_0-1643771653996.png

vkkfmsft_2-1643771707916.png

 

If you want to attach the underlying data, try merging the two tables in the Power Query Editor.

 

    vkkfmsft_6-1643771915968.png

vkkfmsft_7-1643771975097.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

amitchandak
Super User
Super User

@FrederikB , Hope there is 1-M join. Try to add filter for measure and check

Service fee = calculate(sum('Line items'[Value]),filter('Line items', 'Line items'[data.invoices.lineItems.Title]="Service fee"))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 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.