Forum Discussion
calculation for "other" using rank
Hi all,
I need to create a table visualization in Power BI that displays projects along with their values. However, I only consider projects where [BP without IT] > 1M.
The ranking should be applied to these projects based on their [BP without IT] values in descending order. If a project is ranked above 10, it should be grouped under "Other Projects over 1M", and instead of individual values, it should display the sum of all projects ranked between 10 and the max rank (i.e., all projects with a value above 1M).
Additionally, if a project has [BP without IT] < 1M, its rank should be blank (not calculated).
Current Issue:
The issue I am facing is that for projects ranked above 10, the values are simply repeating the original [BP without IT] instead of displaying the correct aggregated sum of projects ranked between 10 and max.
Expected Behavior:
For example, if the ranks and values are:
Rank Project BP without IT
| 1 | A | 5.0M |
| 2 | B | 4.2M |
| ... | ... | ... |
| 10 | J | 1.8M |
| 11 | K | 1.5M |
| 12 | L | 1.3M |
| 13 | M | 1.2M |
Then "Other Projects over 1M" should display 1.5M + 1.3M + 1.2M = 3.0M, instead of individual values for each project.
___testy =
VAR _baseTable =
ADDCOLUMNS(
FILTER(
SUMMARIZE(
FactTableBP,
FactTableBP[Project Description]
),
[BP without IT] > 1000000
),
"BP_Value", CALCULATE([BP without IT]),
"Rank", IF(
[BP without IT] >= 1000000,
RANKX(
ALL(FactTableBP[Project Description]),
[BP without IT],
, DESC, DENSE
),
BLANK()
)
)
VAR _maxRank = MAXX(_baseTable, [Rank])
VAR _sumOtherProjects =
CALCULATE(
SUMX(
FILTER(
_baseTable,
[Rank] > 10 && [Rank] <= _maxRank
),
[BP_Value]
),
REMOVEFILTERS(FactTableBP[Project Description])
)
RETURN
IF(
[Projects Rank BP] > 10,
_sumOtherProjects,
[BP without IT]
)
How can I ensure that all projects ranked above 10 show the same summed value of projects between rank 10 and max, instead of displaying their individual values?
Would appreciate any suggestions or corrections! Thanks!
Hi Simonn97_PBI
Those ranks numbers need to be materialized using a disconnected table containing the rank numbers and the word other. If the image below is what you're looking for, I have tutorials on YouTube
https://youtu.be/8Ti3rUroIaU?si=MKdU6ogkzvJ5Q9DB
https://youtu.be/CHRkJNHNoxU?si=8geoIs12EOnR0AMK
2 Replies
- danextian
Super User
Hi Simonn97_PBI
Those ranks numbers need to be materialized using a disconnected table containing the rank numbers and the word other. If the image below is what you're looking for, I have tutorials on YouTube
https://youtu.be/8Ti3rUroIaU?si=MKdU6ogkzvJ5Q9DB
https://youtu.be/CHRkJNHNoxU?si=8geoIs12EOnR0AMK
- bhanu_gautam
Super User
First, create a calculated column to rank the projects based on [BP without IT] in descending order.
Rank =
IF (
FactTableBP[BP without IT] > 1000000,
RANKX (
FILTER ( FactTableBP, FactTableBP[BP without IT] > 1000000 ),
FactTableBP[BP without IT],
,
DESC,
DENSE
),
BLANK()
)Next, create a measure to calculate the sum of [BP without IT] for projects ranked above 10.
SumOtherProjects =
VAR _baseTable =
FILTER (
FactTableBP,
FactTableBP[BP without IT] > 1000000
)
VAR _maxRank = MAXX (_baseTable, FactTableBP[Rank])
RETURN
CALCULATE (
SUMX (
FILTER (
_baseTable,
FactTableBP[Rank] > 10 && FactTableBP[Rank] <= _maxRank
),
FactTableBP[BP without IT]
),
REMOVEFILTERS (FactTableBP[Project Description])
)Finally, create a measure to display the correct value based on the rank.
DisplayValue =
IF (
FactTableBP[Rank] > 10,
[SumOtherProjects],
FactTableBP[BP without IT]
)