Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
I'm trying to make a dynamic Scoreboard for a sales department and everything works fine except for one thing: calculating the differences for each line.
I know that i could do it with Power Query by using two index columns and then just merge them, but that would make it static. I want to be able to compare different groups of people and it should automaticly update the rank and differences in the current list.
The list looks something like this at the moment. In the example I have choosen 6 members to compare but I might need to switch them out and the values should then be calculated based on the new table.
Details
Rank = RANKX(ALLSELECTED('Sales people');[Sum];[Sum];DESC;Dense)
Sum = This is just a measure that adds a couple of sum-functions from various tables
The Diff Sum to Rank 1 is first a measure that calculates the top sum and then it subtracts the sales persons sum from that:
Sum for Rank 1 = CALCULATE(MAXX('Sales people';[Sum]);ALLSELECTED('Salespeople'))
Diff Sum to Rank 1 = [Sum]-[Sum for Rank 1]
So far so good! What I want now is a measure that calculates the difference between each sales person and the one above in the score list.
This is how I would have done it with Excel if I had a static list.
Any ideas?
Solved! Go to Solution.
Hi @Anonymous
My answer below is modelled on the useful patterns in this article
https://www.sqlbi.com/articles/displaying-nth-element-in-dax/
Diff to next person = VAR CurrentRank = [Rank] VAR CurrentSum = [Sum] VAR NextPerson = FILTER ( ALLSELECTED ( 'Sales people' ); [Rank] = CurrentRank - 1 ) VAR NextPerson_Sum = MINX ( NextPerson; [Sum] ) RETURN IF ( NOT ISBLANK ( NextPerson_Sum ); CurrentSum - NextPerson_Sum )
This formula basically filters Sales People to the current rank minus 1, and evaluates Sum for that sales persion (using MINX in case of tied ranks for the next person).
Regards,
Owen
Hi @Anonymous
My answer below is modelled on the useful patterns in this article
https://www.sqlbi.com/articles/displaying-nth-element-in-dax/
Diff to next person = VAR CurrentRank = [Rank] VAR CurrentSum = [Sum] VAR NextPerson = FILTER ( ALLSELECTED ( 'Sales people' ); [Rank] = CurrentRank - 1 ) VAR NextPerson_Sum = MINX ( NextPerson; [Sum] ) RETURN IF ( NOT ISBLANK ( NextPerson_Sum ); CurrentSum - NextPerson_Sum )
This formula basically filters Sales People to the current rank minus 1, and evaluates Sum for that sales persion (using MINX in case of tied ranks for the next person).
Regards,
Owen
It works like a charm! Thanks!
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
104 | |
101 | |
79 | |
72 | |
64 |
User | Count |
---|---|
142 | |
108 | |
101 | |
81 | |
74 |