Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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.
User | Count |
---|---|
25 | |
12 | |
8 | |
6 | |
6 |
User | Count |
---|---|
26 | |
12 | |
11 | |
10 | |
6 |