Supplies are limited. Contact info@espc.tech right away to save your spot before the conference sells out.
Get your discountScore big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount
Hello everyone
I'm implementing a measure to identify the TOP5 Values in our dataset, which functions correctly except when dealing with duplicate percentage values. The measure becomes unreliable when encountering tied values.
I attempted a workaround by first calculating TOP10 values and then filtering down to TOP5, but this approach also proves inconsistent. Below you'll find my current implementation and sample data. I'm seeking guidance on how to properly handle scenarios where multiple records share the same percentage value while maintaining accurate TOP5 selection.
Code | money_budget | diff_measure | Top 10 measure |
147 | $676478 | 23% | 1 |
061 | $1702280 | 9% | 0 |
169 | $1344044 | 9% | 1 |
124 | $4087457 | 5% | 1 |
074 | $831424 | 5% | 1 |
031 | $682472 | 2% | 1 |
068 | $8692267 | 2% | 1 |
036 | $396112 |
| 0 |
043 | $122531 |
| 0 |
083 | $3330222 | 0% | 1 |
111 | $582983 | -2% | 1 |
135 | $2328999 | -4% | 1 |
067 | $675176 | -4% | 1 |
118 | $9642842 | -4% | 0 |
027 | $1592563 | -7% | 0 |
162 | $989317 | -8% | 0 |
123 | $1235861 | -8% | 0 |
151 | $1687651 | -9% | 0 |
134 | $4851934 | -9% | 0 |
173 | $1116056 | -14% | 0 |
Solved! Go to Solution.
Thank you FreemanZ
Hi, @julsr
According to your description, I created the following dataset:
First, I created a date table using the following DAX expression:
Date = VALUES('Table'[Date])
I then created a measure using this expression:
MEASURE =
VAR CurrentClient =
SELECTEDVALUE ( 'Table'[Code] )
VAR MinDate =
MIN ( 'Date'[Date] )
VAR Top10Values =
ADDCOLUMNS (
FILTER (
ALL ( 'Table' ),
'Table'[money_budget] > 400000
&& 'Table'[Date] = MinDate
),
"aa",
RANK (
DENSE,
ALLSELECTED ( 'Table' ),
ORDERBY ( 'Table'[new_measure_rounded], DESC, 'Table'[Code], DESC )
)
)
VAR Top5 =
SUMMARIZE (
SELECTCOLUMNS ( FILTER ( Top10Values, [aa] <= 5 ), "Code", 'Table'[Code] ),
[Code]
)
RETURN
IF ( CurrentClient IN Top5, 1, 0 )
Create a slicer using the Date table, and then place this measure into the Table visual:
When the TopN function cannot meet your needs, you can usually achieve a similar effect through the rank function.
How to Get Your Question Answered Quickly
If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .
Best Regards
Jianpeng Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, @julsr
This is a new question. You can ask it in a new thread and I believe someone will help you optimize your expression soon.
Best Regards
Jianpeng Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hello! Just commenting to see if anyone knows how to solve it, thanks 🙏
Thank you FreemanZ
Hi, @julsr
According to your description, I created the following dataset:
First, I created a date table using the following DAX expression:
Date = VALUES('Table'[Date])
I then created a measure using this expression:
MEASURE =
VAR CurrentClient =
SELECTEDVALUE ( 'Table'[Code] )
VAR MinDate =
MIN ( 'Date'[Date] )
VAR Top10Values =
ADDCOLUMNS (
FILTER (
ALL ( 'Table' ),
'Table'[money_budget] > 400000
&& 'Table'[Date] = MinDate
),
"aa",
RANK (
DENSE,
ALLSELECTED ( 'Table' ),
ORDERBY ( 'Table'[new_measure_rounded], DESC, 'Table'[Code], DESC )
)
)
VAR Top5 =
SUMMARIZE (
SELECTCOLUMNS ( FILTER ( Top10Values, [aa] <= 5 ), "Code", 'Table'[Code] ),
[Code]
)
RETURN
IF ( CurrentClient IN Top5, 1, 0 )
Create a slicer using the Date table, and then place this measure into the Table visual:
When the TopN function cannot meet your needs, you can usually achieve a similar effect through the rank function.
How to Get Your Question Answered Quickly
If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .
Best Regards
Jianpeng Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Awesome, thanks for sharing this valuable information and report! However, I have another problem now:
Resource Governing: This query uses more memory than the configured limit. The query — or calculations referenced by it — might be too memory-intensive to run. Either reach out to your Analysis Services server administrator to increase the per-query memory limit or optimize the query so it consumes less memory. More details: consumed memory 1024 MB, memory limit 1024 MB.
The main problem is that diff_measure is a measure that uses another 3 measures:
Hi, @julsr
This is a new question. You can ask it in a new thread and I believe someone will help you optimize your expression soon.
Best Regards
Jianpeng Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thanks, did something similar, for the [diff_measure] I used a round and then multiplied by 1000 to avoid decimals but it is not working.
This is the code and below are the data and results
Code | money_budget | new_measure_rounded | code_top5 |
147 | $676478 | 2320 | 1 |
061 | $1702280 | 941 | 0 |
169 | $1344044 | 932 | 1 |
124 | $4087457 | 522 | 1 |
074 | $831424 | 515 | 1 |
031 | $682472 | 222 | 1 |
068 | $8692267 | 219 | 0 |
036 | $396112 |
| 0 |
043 | $122531 |
| 0 |
083 | $3330222 | 0% | 0 |
111 | $582983 | -222 | 0 |
135 | $2328999 | -415 | 0 |
067 | $675176 | -498 | 0 |
118 | $9642842 | -499 | 0 |
027 | $1592563 | -743 | 0 |
162 | $989317 | -898 | 0 |
123 | $1235861 | -899 | 0 |
151 | $1687651 | -934 | 0 |
134 | $4851934 | -976 | 0 |
173 | $1116056 | -1412 | 0 |