Forum Discussion
TOP N Disappear
Hello everyone,
I need some help, please.
I'm trying to create a table with Top N depending of the amount of employees.
This is my measure:
------------------------
---------------------
The problem is that when using this formula inside the above
VAR CantPract =
But, when I put a number instead the formula a result is shown, for example
VAR CantPract = 14
Why is that? How could I do a correct measure depending of the amount of employees?
This is the empleado's table in case need it
Hi Antonio_Gomez ,
According to your code, I create a sample and test. If you put the CantPract part in the RETURN field, you will find it take each row into consideration instead of the whole table.
Modify it to:
TopNPracticos = VAR CantPract = CALCULATE ( COUNT ( Empleado[CodigoPractico] ), ALL ( 'Empleado' ) ) VAR TopNValue = ROUNDUP ( CantPract / 2, 0 ) VAR TopPPracticos = TOPN ( TopNValue, ALLSELECTED ( Empleado ), Empleado[Mov] ) VAR TopNManiobras = CALCULATE ( SELECTEDVALUE ( Empleado[Mov] ), KEEPFILTERS ( TopPPracticos ), FILTER ( Empleado, Empleado[CodigoPractico] <> "X" ) ) RETURN TopNManiobrasGet the correct result:
I attach my sample below for your reference.
Best Regards,
Community Support Team _ kalyjIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
2 Replies
- amitchandakSuper User
Antonio_Gomez , Please TOP N like
Top 1 = CALCULATE([Measure],TOPN(TopNValue ,all(Table[product]),[Measure],DESC),VALUES(Table[product]))
Power BI- Power BI- TOPN with Others- https://youtu.be/I_TY4hVlzAE
- v-yanjiang-msftCommunity Support
Hi Antonio_Gomez ,
According to your code, I create a sample and test. If you put the CantPract part in the RETURN field, you will find it take each row into consideration instead of the whole table.
Modify it to:
TopNPracticos = VAR CantPract = CALCULATE ( COUNT ( Empleado[CodigoPractico] ), ALL ( 'Empleado' ) ) VAR TopNValue = ROUNDUP ( CantPract / 2, 0 ) VAR TopPPracticos = TOPN ( TopNValue, ALLSELECTED ( Empleado ), Empleado[Mov] ) VAR TopNManiobras = CALCULATE ( SELECTEDVALUE ( Empleado[Mov] ), KEEPFILTERS ( TopPPracticos ), FILTER ( Empleado, Empleado[CodigoPractico] <> "X" ) ) RETURN TopNManiobrasGet the correct result:
I attach my sample below for your reference.
Best Regards,
Community Support Team _ kalyjIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.