0
votes

I have a table in my visualization.

with the following fields

Level1, Type ID, Group ID, Starting Value, Commission, Sales Amount, Calc Bonus  Bonus 
1       3        15000           19,83898.38        
1       3        17500           29,838196.75196.75
1       3        110000          39,838         
1       3        112500          49,838 
1       3        115000          59,838 
1       3        117500          69,838 
1       3        120000          79,838 
1       3        220000          1119,2311,192.31
1       3        240000          2119,2312,384.63
1       3        260000          3119,2313,576.943,576.94

I calculated in a measure BONUS Calc with

BONUS Calc = 
     SUMX(FILTER('table', 
          AND ('table'[Type] = 3, 
               'table1'[Sales Amount] >=  'Table'[Starting Value])),
          'table1'[Sales Amount] * 'table'[Commission])

But what I want is the column Bonus

Basically, I want to filter by Level 1, Type ID, Group ID Check the first Starting value <= Sales Amount and calculate de Commission... The problem is I have a calculation for all the Starting value <= Sales Amount I only want the first one.

I thought I can do a Max with filters to my measure column Bonus Calc but I didn't find the solution...

I appreciate if someone can give me a clue. Thanks

Dim Group
Groupkey  Group 
1         group1
2         group2
3         group3
4         group4
5         group5
Table1 
Groupkey SalesAmount 
1        €9838
2        €119231
3        
Table 
Level1 ID Level1 GroupKey Group   Type ID Type  Starting value Comission
1         Lev1   1        group1  1       type15000          1%
1         Lev1   1        group1  1       type17500          2%
1         Lev1   1        group1  1       type110000         3%
1         Lev1   1        group1  1       type112500         4%
1         Lev1   1        group1  1       type115000         5%
1         Lev1   1        group1  1       type117500         6%
1         Lev1   1        group1  1       type120000         7%
1         Lev1   1        group1  2       type120000         1%
1         Lev1   1        group1  2       type140000         2%
1         Lev1   1        group1  2       type160000         3%
1
can you explain how table and table1 are linked together?Joao Leal
Table and Table 1 aren't linked together they are fact tables and in between, there is a Dim table Group so the tables are linked to Dim Groupofeliajesus
Provide some sample data and expected outcome for those 3 tables.mxix
I provided an image with samplesofeliajesus
the format of data is crazy ....ofeliajesus

1 Answers

0
votes

So to calculate your commission you need to know the sales prices, and you'd do it like this:

comission = 
       var sales = SUM(table1[SalesAmount])
       RETURN CALCULATE(MAX(table[comission]), 
          ALL(table[starting value]), table[starting value] <= sales)

To calculate your bonus amount you just expand on the previous calculation:

bonus = 
    var sales = SUM(table1[SalesAmount])
    var comission = CALCULATE(MAX(table[comission]), 
      ALL(table[starting value]), table[starting value] <= sales)
    Return comission * sales