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 to All,
I am having a problem with a code to return a value based in multiple criteria, comparing multiple columns in two different tables.
I have the error message after I run the code.
Error Expression.Error: We cannot convert the value false to type Function."
let
relevantT = Table.SelectRows(Scores, each (Scores[AgeCategory]=FtJump[AgeCategory] and Scores[Position] = FtJump[ScorePosition] and Scores[Gender] = FtJump[#"Gender:"] and Scores[Protocol]= FtJump[JumpProtocol])),
valueat100 = List.MinN(Table.SelectRows(relevantT,Scores[ScorePercent] = 100),Scores[ScoreValue]),
valueat5 = List.MinN(Table.SelectRows(relevantT,Scores[ScorePercent] = 5),Scores[ScoreValue]),
orderIsdescending = valueat100 > valueat5,
percentil = if orderIsdescending
then List.MaxN( Table.SelectRows(relevantT, FtJump[JumpProtocol] >= Scores[ScoreValue]),Scores[ScorePercent])
else List.MinN( Table.SelectRows(relevantT, FtJump[JumpProtocol] >= Scores[ScoreValue]),Scores[ScorePercent]),
result = percentil
in
result
If please anyone can help me to check where is the error?
Thanks a lot.
Hi @Anonymous ,
Try changing this:
Table.SelectRows(relevantT, FtJump[JumpProtocol] >= Scores[ScoreValue])
by:
Table.SelectRows(relevantT, each FtJump[JumpProtocol] >= Scores[ScoreValue])
Insert the each keyword in every Table.SelectRows function.
Many Thanks @camargos88
I just insert the EACH in all the Table.SelectRows functions.
But now the error has changed.
Expression.Error: We cannot convert a value of type Table to type List.
Why is that?
@Anonymous ,
Are you brazilian ?
Check this code:
List.MinN(Table.SelectRows(relevantT, each Scores[ScorePercent] = 100),Scores[ScoreValue])
It should be something like:
List.MinN(Table.SelectRows(relevantT, each Scores[ScorePercent] = 100)[COLUMN],Scores[ScoreValue])
Yes i am Brazilian,
The [COLUMN] you said refering to what? Because i understand as i refere to a diffrent table i cant jus put the column name, isnt?
Melhor eu falando em portugues irei me explicar melhor.
Brigado.
Eu entendi e tentei inverter os parametros todos mas não funcionou do mesmo jeito,
let
relevantT = Table.SelectRows(Scores, each (Scores[AgeCategory]=FtJump[AgeCategory] and Scores[Position] = FtJump[ScorePosition] and Scores[Gender] = FtJump[#"Gender:"] and Scores[Protocol]= FtJump[JumpProtocol])),
valueat100 = List.MinN(Scores[ScoreValue],Table.SelectRows(relevantT, each Scores[ScorePercent] = 100)),
valueat5 = List.MinN(Scores[ScoreValue],Table.SelectRows(relevantT, each Scores[ScorePercent] = 5)),
orderIsdescending = valueat100 > valueat5,
percentil = if orderIsdescending
then List.MaxN( Scores[ScorePercent],Table.SelectRows(relevantT, each FtJump[JumpProtocol] >= Scores[ScoreValue]))
else List.MinN( Scores[ScorePercent],Table.SelectRows(relevantT, each FtJump[JumpProtocol] >= Scores[ScoreValue])),
result = percentil
in
result
Tentei primeiro o parametro da coluna que possui a lista de valores depois a condição que seria para retornar o valor correto mas mesmo assim continua aparecendo o mesmo erro.
@Anonymous,
O problema aqui é que vc estava passando uma tabela onde ele espera uma lista. Por exemplo:
List.MaxN(Table.SelectRows(relevantT, FtJump[JumpProtocol] >= Scores[ScoreValue]),Scores[ScorePercent])
Nessa parte em negrito no seu código está uma tabela e vai dar erro pq vai tentar converter uma tabela em lista.
Ai você precisa retornar uma lista (que nesse caso é uma coluna da sua tabela). Por exemplo:
List.MaxN(Table.SelectRows(relevantT, FtJump[JumpProtocol] >= Scores[ScoreValue])[COLUNA],Scores[ScorePercent])
Essa [COLUNA] é a que você quer usar como lista. Você precisa fazer essa conversão implicita senão vai dar erro de conversão de tabela pra lista.
Eu não entendi o que você quer fazer, pq o PBIX não carrega no Power Query sem a fonte de dados, e talvez tenha alguma outra forma. Porém acredito que se você colocar o parametro dessa forma que eu falei acima, vai dar certo.
Então @camargos88
List.MaxN(Table.SelectRows(relevantT, FtJump[JumpProtocol] >= Scores[ScoreValue])[COLUNA],Scores[ScorePercent])
Neste caso quero listar os valores máximos (List.MaxN), que atendem as condições (Table.SelectRows(relevantT, FtJump[JumpProtocol] >= Scores[ScoreValue]), na coluna de (Scores[ScorePercent])).
O parametro [COLUNA] que voce incluiu significa que tenho que transformar as minhas condições em coluna?
----
Falando sobre o que eu necessito, eu tenho varias tabelas de testes fisicos, SALTO, VELOCIDADE, POTENCIA
Cada tabela tem resultados de testes de varios atletas.
Esses resultados cada resultado dentro de um universo de atletas representa um PERCENTIL, ex um SALTO de 30cm dentro do universo de atletas HOMENS, 17ANOS, ZAGUEIROS é 80% melhor dos saltos.
Antes estava criando em DAX e consegui criar com o seguinte codigo:
ScoreFatigue =
VAR relevantT_ = FILTER(Scores;Scores[AgeCategory]=FtAnaerobic[AgeCategory] && Scores[Position] = FtAnaerobic[ScorePosition] && Scores[Gender] = FtAnaerobic[Gender:] && Scores[Protocol]= FtAnaerobic[Protocol])
VAR valueat100_ = MINX(FILTER(relevantT_;Scores[ScorePercent] = 100);Scores[ScoreValue])
VAR valueat5_ = MINX(FILTER(relevantT_;Scores[ScorePercent] = 5);Scores[ScoreValue])
VAR orderIsdescending_ = valueat100_ > valueat5_
VAR percentile_ =
IF(orderIsdescending_;
MAXX( FILTER(relevantT_; FtAnaerobic[Fatigue] >= Scores[ScoreValue]);Scores[ScorePercent]);
MINX( FILTER(relevantT_; FtAnaerobic[Fatigue] >= Scores[ScoreValue]);Scores[ScorePercent]))
RETURN
percentile_
Mas o que acontece, preciso fazer um grafico RADAR onde preciso colocar meus dados em linha.
Data - Atleta - Protocolo - Percentil
Assim conseguiria fazer um grafico Radar, e em DAX nao consigo fazer isto, assim tentei adaptar o codigo de DAX para M para poder criar uma consulta com as colunas de PERCENTIL mescladas e depois transpostas em linhas.
Fiz uma confusao nao sei se consegui explicar.
@Anonymous ,
"O parametro [COLUNA] que voce incluiu significa que tenho que transformar as minhas condições em coluna?"
Não, primeiro vc filtra a sua tabela, e depois o retorno precisa ser tipado como uma lista.
Table.SelectRows(TABELA, each COLUNA >= 123456)[AQUI VC RETORNA A COLUNA QUE VAI USAR COMO RETORNO]
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 19 | |
| 10 | |
| 9 | |
| 7 | |
| 7 |