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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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"))

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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