Forum Discussion
Sumx with Meassure
Hi Guys i need help with adjusting my sumxfunction.
I have 2 tables.
1st:
Country | Product | APN |
UK | A | 20 |
UK | B | 10 |
| US | A | 30 |
| US | B | 10 |
2nd:
| Country | Expenses |
| UK | 100 |
| US | 200 |
Both tables have relationship via Country. And what i would like to calculate is the expeses after aplying factor per individual product. Expenses are allocated via the amount of Premium (APN).
Hence i created meassure to have factor for individual product and country like this since i will be looking at the allocation only per individual country.
Factor = DIVIDE(SUM(Data[APN]),CALCULATE(SUM(Data[APN]),ALLSELECTED()))
So for UK the visual will look like this.
| Country | Product | APN | Factor |
| UK | A | 20 | 0,67 |
| UK | B | 10 | 0,33 |
And now i need to to do sumx where i need to split the expenses from the second tabel and bring it into first one.
What i made is this but it is not working as it should.
SUMX(VALUES(Data[Product)]),[Factor]*SUM(Expenses[Expenses]))
My final visual should look like this but instead i get 300 for each product.
| Country | Product | APN | Factor | Expenses |
| UK | A | 20 | 0,67 | 67 |
| UK | B | 10 | 0,33 | 33 |
Any idea what am i doing wrong?
Thank you.
While using an expression from other table , use RELATED Function. Try let me know that worked?
stanislav_dugas solution attached, check measures in APN table, there are few more tables in the model, just ignore those.
For this post, APN and Expenses are the relevant tables.
Check my latest blog post Compare Budgeted Scenarios vs. Actuals I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!
⚡Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.⚡
4 Replies
- VijayPCommunity Champion
While using an expression from other table , use RELATED Function. Try let me know that worked?
- stanislav_dugasHelper III
Perfect this solved my problem Related function brought the expenses into my main table and then i was able to quickly calculate it 🙂 thx alot
- parry2kSuper User
stanislav_dugas solution attached, check measures in APN table, there are few more tables in the model, just ignore those.
For this post, APN and Expenses are the relevant tables.
Check my latest blog post Compare Budgeted Scenarios vs. Actuals I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!
⚡Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.⚡
- stanislav_dugasHelper III
Thx alot this solved another problem now my factor is calculated properly even when looking on various countries at once 🙂 thx alot