Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
Hello everyone,
Complete newbie to Powerbi here, I'm wrestling with some Dax code that I hoped someone could help me with....
Salestable
| Name | Store | Department | Gender | Sales |
| Joe Bloggs | Highways | Electrical | Male | $550 |
| Sam Smith | Chandler | Homeware | Male | $400 |
| Susan Brown | Highways | Homeware | Female | $350 |
| Jenny Shaw | Highways | Garden | Female | $900 |
| Gordon Murphy | Chandler | Electrical | Male | $500 |
The first thing I wanted to do was to create a dynamic measure that changed depending on the variables (Store, Department, Gender)
I used the code
| Name | Store | Department | Gender | Sales | Staffdynamicrank |
| Jenny Shaw | Highways | Garden | Female | $900 | 1 |
| Joe Bloggs | Highways | Electrical | Male | $550 | 2 |
| Susan Brown | Highways | Homeware | Female | $350 | 3 |
However, from here it gets complicated, I want to create a bonus column for the top 4 based on the current filter chosen by the end user, so if ranked 1 bonus = $200, 2 - $150, 3 - $100, 4 - $50
I am trying to do something along the lines of
Bonus = sumx(
Salestable,
IF([Staffdynamicrank]=1,$200,0))
I can't get this to work just for one bonus...:(
I'd like to do some more complicated things, based on the amount that the staff member has earned - if they are so far ahead of the other people they get their bonus added on as well, but for now I'd just like to be able to use the IF function with the measure I have.
Thanks
Tom
Solved! Go to Solution.
Hi, @tomshaw83 , you're only an inch away from your goal of bonus calculation. You might want to try the following measure,
Bonus = SWITCH ( [Staffdynamicrank], 1, 200, 2, 150, 3, 100, 4, 50 )
One point worth paying attention to is your measure
Staffdynamicrank = RANKX( ALLSELECTED(Sales[Name]), ... )is relative ranking since you might want them to be dynamic. Thus, any other measures referencing the rank measure also work in a relative manner.
| Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
Hi, @tomshaw83 , you're only an inch away from your goal of bonus calculation. You might want to try the following measure,
Bonus = SWITCH ( [Staffdynamicrank], 1, 200, 2, 150, 3, 100, 4, 50 )
One point worth paying attention to is your measure
Staffdynamicrank = RANKX( ALLSELECTED(Sales[Name]), ... )is relative ranking since you might want them to be dynamic. Thus, any other measures referencing the rank measure also work in a relative manner.
| Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 6 | |
| 6 | |
| 4 | |
| 4 | |
| 4 |
| User | Count |
|---|---|
| 24 | |
| 17 | |
| 9 | |
| 7 | |
| 6 |