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
MarcusR1
Helper I
Helper I

Combine multiple Order Items into single Orders

Hi.

I feel embarrased to ask this becasue it seems that should be so simple!

I have database tables Orders and Order Items.

Orders contain the details of the order (date, customer ID, etc) and the Order items contain the individual products that make up the order.
I have used Merge Queries and used Inner Join to connect the two databases on the OrderID

MarcusR1_0-1656929374141.png

but when I expand the orders table, I now have multiple lines for each order

MarcusR1_1-1656929581522.png

which means that when I use a basic table in the View to display OrderID and Value, it is calculating the value twice for and order with two items, three times for an order with three items, four times for an order with four items, etc

MarcusR1_2-1656929674542.png

 

I have connected the tables in the relationship manager

MarcusR1_3-1656929748180.png

 

This seems like a fundamental use of PowerBI but I can't get my small brain around it!
Please help
Thanks

 

1 ACCEPTED SOLUTION
BA_Pete
Super User
Super User

Hi @MarcusR1 ,

 

It looks like you're combining two different methods of relating data in the same solution: 1) you're merging the tables together and, 2) you're relating them together as well.

 

For standard reporting on this type of data in Power BI, I would recommend to remove the merge process and just relate the two tables in the data model. Without doing the merge first, you should find that your relationship between PC_ORDERS[OrderID] and PC_ORDER_ITEMS[OrderID] becomes a ONE-to-MANY relationship, and both tables can be reported on in relation to one another.

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




View solution in original post

4 REPLIES 4
MarcusR1
Helper I
Helper I

Thanks for your help @BA_Pete it's showing the correct figures now. It turns out that the correct cardinology is essential in the relationships, otherwise none of the figures work and I get errors everywhere!

MarcusR1
Helper I
Helper I

Thank you @BA_Pete I've created one-way relationships and removed the inner joins and it give sthe correct figures now, but now it appears that I have to use lookupvalue for all the other reports, I would have thought that joining them at the source would make more sense.....

Hi @MarcusR1 ,

 

I don't think you should need to use LOOKUPVALUE very much. Just make sure that you always use the PC_ORDERS[OrderID] in measures and visuals and any values from PC_ORDER_ITEMS will always be filtered as relevant.

 

If there's a specific calculation or structure your trying to achieve, I'm happy to help with that if you can provide details, otherwise what you've done so far and my note above should be everything you need.

 

Pet



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




BA_Pete
Super User
Super User

Hi @MarcusR1 ,

 

It looks like you're combining two different methods of relating data in the same solution: 1) you're merging the tables together and, 2) you're relating them together as well.

 

For standard reporting on this type of data in Power BI, I would recommend to remove the merge process and just relate the two tables in the data model. Without doing the merge first, you should find that your relationship between PC_ORDERS[OrderID] and PC_ORDER_ITEMS[OrderID] becomes a ONE-to-MANY relationship, and both tables can be reported on in relation to one another.

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




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.

Top Solution Authors
Top Kudoed Authors