Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
SanGraham
Helper I
Helper I

Error Expression.Error: We cannot convert the value false to type Function."

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.

10 REPLIES 10
camargos88
Community Champion
Community Champion

Hi @SanGraham ,

 

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.



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



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?

Hi @SanGraham ,

 

Can you share a sample of your pbix ? So I can take a closer look.



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



@SanGraham ,

 

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])

 



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



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?

@SanGraham ,

 

Funções de lista recebem o primeiro parametro de lista, me parece que está colocando uma tabela. Por isso a estrutura

Table.SelectRows(Tabela.....)[COLUNA]... assim você força um retorno de lista.



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



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.

@SanGraham,

 

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.

 

Capture.PNG



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



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.

@SanGraham ,

 

"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]

 

 



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors