Forum Discussion

Mazex1985's avatar
Mazex1985
New Member
5 years ago
Solved

Showing percentage from two different datasets

Hello,

  I have three tables like the below

 

Users

Earnings

Expenses

 

I am showing one table on powerbi, that shows each user with his earnings and expenses next to him, I want to add another column that shows the percentage of earnings over expenses, but when i add that column (sum(earnings)/sum(expenses) to the users table, it's showing percentage for all users,  I need it to be filtering per user, am i doing it wrong

 

Thanks.

  • Hi Mazex1985 

    Do you create relationships between Users table and other two tables based on User columns? I would recommend using a measure to get the percentage.

    Percentage = DIVIDE(SUM(Earnings[Earnings]),SUM(Expenses[Expenses]))

     

    You can also get it with a calculated column in Users table. Here is a sample pbix.

    Column = DIVIDE(SUMX(FILTER(Earnings,Earnings[Users]=EARLIER(Users[Users])),Earnings[Earnings]),SUMX(FILTER(Expenses,Expenses[Users]=EARLIER(Users[Users])),Expenses[Expenses]))

    Kindly let me know if this helps.
    Community Support Team _ Jing Zhang
    If this post helps, please consider Accept it as the solution to help other members find it.

4 Replies

  • Mazex1985 

    Did you connect your tables with calendar table ? 

    Can you show us the data model ? 🙂

  • v-jingzhang's avatar
    v-jingzhang
    Icon for Community Support rankCommunity Support

    Hi Mazex1985 

    Do you create relationships between Users table and other two tables based on User columns? I would recommend using a measure to get the percentage.

    Percentage = DIVIDE(SUM(Earnings[Earnings]),SUM(Expenses[Expenses]))

     

    You can also get it with a calculated column in Users table. Here is a sample pbix.

    Column = DIVIDE(SUMX(FILTER(Earnings,Earnings[Users]=EARLIER(Users[Users])),Earnings[Earnings]),SUMX(FILTER(Expenses,Expenses[Users]=EARLIER(Users[Users])),Expenses[Expenses]))

    Kindly let me know if this helps.
    Community Support Team _ Jing Zhang
    If this post helps, please consider Accept it as the solution to help other members find it.