Forum Discussion
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
but when I expand the orders table, I now have multiple lines for each order
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
I have connected the tables in the relationship manager
This seems like a fundamental use of PowerBI but I can't get my small brain around it!
Please help
Thanks
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
4 Replies
- BA_PeteSuper 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
- BA_PeteSuper User
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