Forum Discussion

stanislav_dugas's avatar
stanislav_dugas
Helper III
5 years ago
Solved

Sumx with Meassure

Hi Guys i need help with adjusting my sumxfunction.

 

I have 2 tables.

1st:

Country

ProductAPN

UK

A20

UK

B10
USA30
USB10

2nd:

CountryExpenses
UK100
US200

 

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.

CountryProductAPNFactor
UKA200,67
UKB100,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.

CountryProductAPNFactorExpenses
UKA200,6767
UKB100,3333

 

Any idea what am i doing wrong?

Thank you.

  • 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

  • VijayP's avatar
    VijayP
    Community Champion

    stanislav_dugas 

    While using an expression from other table , use RELATED Function. Try let me know that worked?

    • stanislav_dugas's avatar
      stanislav_dugas
      Helper 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

  • 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_dugas's avatar
      stanislav_dugas
      Helper III

      Thx alot this solved another problem now my factor is calculated properly even when looking on various countries at once 🙂 thx alot