Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hello,
I am trying to convert the following sequence of calculation from an excel file to power bi, but am unable to do so with the last one avergeifs formula as it is not existing in power bi for some reason. So i have a column that i need to rank (values will vary per ID). I do that using new calculated column:


I need to do the averageifs but not sure how in power bi. Hope someone can help. Thanks in advance. Solved! Go to Solution.
Hi @natabird3 ,
First I create a calculate column to rank value, you can another rank function as well,
Rank = RANKX('Table2','Table2'[Value],,DESC)
Then in another table, create a number column
Number = ROUND(COUNTROWS(Table2) * [TOP N],0)
Then we can create a measure to calculate the result.
Result =
FORMAT (
AVERAGEX (
FILTER ( ALL ( Table2 ), [Rank] <= SELECTEDVALUE ( 'Calculate'[Number] ) ),
[Value]
),
"Percent"
)
Or we can just use a calculate column to get same result
ResultColumn =
FORMAT (
AVERAGEX ( FILTER ( Table2, [Rank] <= [Number] ), [Value] ),
"Percent"
)
BTW, pbix as attached.
Best regards,
Community Support Team _ DongLi
If this post helps, then please consider Accept it as the solution to help the other members find it more
Hi @natabird3 ,
The measure is dynamic but the calculated columns are computed during the database processing and then stored in the model. So In your scenario, we can only create a measure using following DAX to meet your requirement:
Result =
VAR n =
ROUND ( COUNTROWS ( 'Table' ) * SUM ( 'Calculate'[TOP N] ), 0 )
VAR t =
ADDCOLUMNS ( 'Table', "rank", RANKX ( 'Table', [Value],, DESC ) )
RETURN
FORMAT ( AVERAGEX ( FILTER ( t, [rank] <= n ), [Value] ), "Percent" )
BTW, pbix as attached.
Best regards,
Community Support Team _ DongLi
If this post helps, then please consider Accept it as the solution to help the other members find it more
Hi @natabird3 ,
First I create a calculate column to rank value, you can another rank function as well,
Rank = RANKX('Table2','Table2'[Value],,DESC)
Then in another table, create a number column
Number = ROUND(COUNTROWS(Table2) * [TOP N],0)
Then we can create a measure to calculate the result.
Result =
FORMAT (
AVERAGEX (
FILTER ( ALL ( Table2 ), [Rank] <= SELECTEDVALUE ( 'Calculate'[Number] ) ),
[Value]
),
"Percent"
)
Or we can just use a calculate column to get same result
ResultColumn =
FORMAT (
AVERAGEX ( FILTER ( Table2, [Rank] <= [Number] ), [Value] ),
"Percent"
)
BTW, pbix as attached.
Best regards,
Community Support Team _ DongLi
If this post helps, then please consider Accept it as the solution to help the other members find it more
Hello @v-lid-msft ,
Thank you for the proposed solution, i thought it works when i tried to implement it but now when i filter i am unable to get the desired result. I believe because of how we set the number formula, it counts the rows assuming each row is a different ID maybe, however we have some id's with multiple entries so if i filter per id i am not getting the desired result as nothing changes. For example, we can have the following situation, in this case i am getting the total for both ID's, anyway to only get per ID? Please let me know, thanks again for your help.

Hi @natabird3 ,
The measure is dynamic but the calculated columns are computed during the database processing and then stored in the model. So In your scenario, we can only create a measure using following DAX to meet your requirement:
Result =
VAR n =
ROUND ( COUNTROWS ( 'Table' ) * SUM ( 'Calculate'[TOP N] ), 0 )
VAR t =
ADDCOLUMNS ( 'Table', "rank", RANKX ( 'Table', [Value],, DESC ) )
RETURN
FORMAT ( AVERAGEX ( FILTER ( t, [rank] <= n ), [Value] ), "Percent" )
BTW, pbix as attached.
Best regards,
Community Support Team _ DongLi
If this post helps, then please consider Accept it as the solution to help the other members find it more
It works perfect, thanks for the help.
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 38 | |
| 38 | |
| 37 | |
| 28 | |
| 28 |
| User | Count |
|---|---|
| 124 | |
| 89 | |
| 73 | |
| 66 | |
| 65 |