Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Calculate Fees of salesman by allocating total sales

Hello there,

 

I am newbie to power bi and I got stacked with something, so I want your help.Please be kind.

 

I have two tables Sales and SalesManFees which looks like:
Table Sales:

YearMonthSales
2022110
2022230
2022320
2022440
2022560

 

Table SalesManFees:

SalesMan IDYearMonthPercentage
12022110
22022140
32022150
12022210

 

What I  want to archive is to take the sum of sales for every month/year  and multipliy it for every salesman with the given percentage.

 

So the desired output will be like :

 

SalesMan IDYearMonthFees
12022110 * 0,10=1
22022110 *0,4 = 4
32022110 *0,5= 5
42022230 * 0*10=1

 

How can I archive this?

Thanks in advance!

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @Anonymous 
Here is a sample file with the solution https://we.tl/t-yfxeDFXk7Z

1.png

Fees = 
SUMX ( 
    SalesManFees,
    SUMX (
        Sales,
        VAR CurrentYear = SalesManFees[Year] 
        VAR CurrentMonth = SalesManFees[Month]
        VAR CurrentPercentage = SalesManFees[Percentage]
        VAR SalesYear = Sales[Year]
        VAR SalesMonth = Sales[Month]
        VAR SalesAmount = Sales[Sales]
        RETURN
            IF (
                CurrentYear = SalesYear && CurrentMonth = SalesMonth,
                SalesAmount * CurrentPercentage / 100
            )
    )
)

View solution in original post

2 REPLIES 2
tamerj1
Super User
Super User

Hi @Anonymous 
Here is a sample file with the solution https://we.tl/t-yfxeDFXk7Z

1.png

Fees = 
SUMX ( 
    SalesManFees,
    SUMX (
        Sales,
        VAR CurrentYear = SalesManFees[Year] 
        VAR CurrentMonth = SalesManFees[Month]
        VAR CurrentPercentage = SalesManFees[Percentage]
        VAR SalesYear = Sales[Year]
        VAR SalesMonth = Sales[Month]
        VAR SalesAmount = Sales[Sales]
        RETURN
            IF (
                CurrentYear = SalesYear && CurrentMonth = SalesMonth,
                SalesAmount * CurrentPercentage / 100
            )
    )
)
daXtreme
Solution Sage
Solution Sage

Here's a link to the solution. The numbers are slightly different since I've changed the input data a bit. But the calculations are correct.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.