Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and a 50 percent discount on exams.
Get startedEarn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
Order |
Order number |
Amount |
Invoice |
Invoice number |
Amount |
Order number |
Solved! Go to Solution.
@Velafyko , create a common dimension of Order number, refer the code in the file
https://www.dropbox.com/s/op9lb78w9utdonz/Distinct%20from%20two%20Tables.pbix?dl=0
refer
https://www.seerinteractive.com/blog/join-many-many-power-bi/
I agree you should improve your model and get rid of the M2M, but FYI there is another way to path the Order Number filter between the tables.
RelatedOrderSum= CALCULATE(SUM(Order[Amount]), TREATAS(VALUES(Invoice[Order number]), Order[Order number]))
You can swap the two order number columns in the TREATAS; not sure which invoice # column you are using in the visual.
If this works for you, please mark it as the solution. Kudos are appreciated too. Please let me know if not.
Regards,
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
Unfortunately I don't get your formula to work. It just gives me the same result as my original formula with the USERELATIONSHIP function. It works when there is only one order, but not when there are multiple orders for an invoice.
Yes, one order can lead to multiple invoices. For instance when not everything ordered is in stock, then what is in stock is shipped together with an invocice. When the remaining items are back in stock, they are shipped with a new invoice from the same order. Ideally we should have exactly one invoice for each order, but it's not always the case.
I hoped I could avoid changing the data model, but it seems like I have no choice then. Thank you 🙂
@Velafyko , create a common dimension of Order number, refer the code in the file
https://www.dropbox.com/s/op9lb78w9utdonz/Distinct%20from%20two%20Tables.pbix?dl=0
refer
https://www.seerinteractive.com/blog/join-many-many-power-bi/
@Velafyko - I would avoid many-to-many relationships like the plague and use a bridge table of unique order numbers.