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
Estefania_89
Frequent Visitor

Sales Target

Hello every one!

 

Could I have help with this problem?. I have a table called  "SALES"  and it  is a  registre of  the sales per category of products . In another table called  "BONUS" i have  the sales goals by category and the bonus they earn if they achieve they sales goal.

I need a measure that  returns the bonus if the goal was achieved and 0 if it doesn´t 

 TABLE  SALES

fechaCATEGORY  SALES AMOUNT 
21/04/2020 0:00PRODUCTO 1960.000
03/04/2020 0:00PRODUCTO 21.290.755
03/04/2020 0:00PRODUCTO 31.290.755
21/04/2020 0:00PRODUCTO 11.290.755
03/04/2020 0:00PRODUCTO 21.290.755
03/04/2020 0:00PRODUCTO 31.290.755
21/04/2020 0:00PRODUCTO 11.290.755
03/04/2020 0:00PRODUCTO 21.290.755
03/04/2020 0:00PRODUCTO 31.290.755
21/04/2020 0:00PRODUCTO 11.290.755

 

Table "Bonus"

CATEGORY SALES TARGETBONUS
PRODUCTO 1 $       1.000.000 $               100.000
PRODUCTO 2 $       2.000.000 $               200.000
PRODUCTO 3 $       3.000.000 $               300.000
PRODUCTO 4 $       4.000.000 $               400.000
PRODUCTO 5 $       5.000.000 $               500.000
3 REPLIES 3
amitchandak
Super User
Super User

@Estefania_89 , refer if attached file after signature can help

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
az38
Community Champion
Community Champion

Hi @Estefania_89 

add a measure in Sales table

isBonus Measure = 
var _curCategory = MAX(Sales[CATEGORY])
var _totalSales = CALCULATE(SUM(Sales[SALES AMOUNT]), ALLEXCEPT(Sales, Sales[CATEGORY]) )
var _target = CALCULATE(MAX(Bonus[Sales target]), Bonus[Category] = _curCategory )

RETURN

IF(_totalSales >= _target, CALCULATE(MAX(Bonus[BONUS]), Bonus[Category] = _curCategory ), 0 )

do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

Hello, 

 

i tried to apply your solution, but this messege came up when i was writting this var: 

 

var _target = CALCULATE(MAX(Bonus[Sales target]), Bonus[Category] = _curCategory )

 

Error: A function 'CALCULATE' has been used in a True/False expression that is used as a table filter expression. This is not allowed.

 

I would like to confirm with you if the solution is what i am looking for, so I have written  an example in case is useful: 

 TABLE  SALES   
fechaCATEGORY  SALES AMOUNT  
21/04/2020 0:00PRODUCTO 1960.000 
03/04/2020 0:00PRODUCTO 2500.000 
03/04/2020 0:00PRODUCTO 32.000.000 
21/04/2020 0:00PRODUCTO 130.000 
03/04/2020 0:00PRODUCTO 21.250.000 
03/04/2020 0:00PRODUCTO 3200.000 
21/04/2020 0:00PRODUCTO 12.390 
03/04/2020 0:00PRODUCTO 2913.000 
03/04/2020 0:00PRODUCTO 3980.200 
21/04/2020 0:00PRODUCTO 13.400 
21/04/2020 0:00PRODUCTO 42.000.000 
21/04/2020 0:00PRODUCTO 4302.000 
    
Table "Bonus"   
CATEGORY SALES TARGETBONUS 
PRODUCTO 1 $       1.000.000 $               100.000 
PRODUCTO 2 $       2.000.000 $               200.000 
PRODUCTO 3 $       3.000.000 $               300.000 
PRODUCTO 4 $       4.000.000 $               400.000 
PRODUCTO 5 $       5.000.000 $               500.000 
    
    
    
SOLUTION   
CATEGORYTOTAL SALES PER CATEGORYSALES TARGET RESULTS
PRODUCTO 1995.7901.000.000 $             -
PRODUCTO 22.663.0002.000.000 $  200.000
PRODUCTO 33.180.2003.000.000 $  300.000
PRODUCTO 42.302.0004.000.000 $             -
PRODUCTO 505000000 $             -

 

So the total sale should be compared to the target sale and the measure return the bonus if the target sale was achieved

Thank yoy very much for your help!

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.