Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register 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! |
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
19 | |
14 | |
14 | |
11 | |
8 |