Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now
Hi everyone,
I would like to calculate the average value of top two values for every section per year&month,
I have tried ranking them first, but I couldn't have a correct ranking.
Do you guys have an idea of how to do it?
Solved! Go to Solution.
Hi @nqahman
Try this MEASURE
Measure = AVERAGEX ( TOPN ( 2, FILTER ( ALL ( TableName ), TableName[YEAR] = SELECTEDVALUE ( TableName[YEAR] ) && TableName[MONTH] = SELECTEDVALUE ( TableName[MONTH] ) && TableName[Section] = SELECTEDVALUE ( TableName[Section] ) ), TableName[VALUE], DESC ), CALCULATE ( SUM ( TableName[VALUE] ) ) )
Hi @nqahman
Try this MEASURE
Measure = AVERAGEX ( TOPN ( 2, FILTER ( ALL ( TableName ), TableName[YEAR] = SELECTEDVALUE ( TableName[YEAR] ) && TableName[MONTH] = SELECTEDVALUE ( TableName[MONTH] ) && TableName[Section] = SELECTEDVALUE ( TableName[Section] ) ), TableName[VALUE], DESC ), CALCULATE ( SUM ( TableName[VALUE] ) ) )
Thank you @Zubair_Muhammad for your response,
An error exists because of too many arguments in the FILTER function.
The maximum number is 2 arguments: Table name and one expression.
I have only 2 arguments in above formula for FILTER
1)
ALL ( TableName )
2)
TableName[YEAR] = SELECTEDVALUE ( TableName[YEAR] ) && TableName[MONTH] = SELECTEDVALUE ( TableName[MONTH] ) && TableName[Section] = SELECTEDVALUE ( TableName[Section] )
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
94 | |
92 | |
82 | |
71 | |
49 |
User | Count |
---|---|
143 | |
121 | |
112 | |
58 | |
57 |