Forum Discussion
If then statement, invalid identifier
Hi John,
Thank you for your help with this. I think I'm not understanding something about what you wrote, that formula returns "token identifier expected" when I write it the way I THINK you intended, it doesn't do anything at all if I paste it directly in, but I think you intended me to change your x,y,z to some kind of actual value?.
I wrote it as...
#"Replaced Value" = Table.ReplaceValue(#"Removed Columns", each [Index], null, (16942,296,null)=> {16942, 296, null}, {"Player IDs.IDFANGRAPHS"})
16942 is the fangraphs ID I want player 296 associated with.
HI coreych,
The (x, y, z)=> in the template for the Replacer function. PBI automatically substitutes parameters to this funciton being: x - current value in the cell which is being checked, y - value which we compare to (this is the second parameter in the Table.ReplaceValue() function , in our case - the [Index] field), z - the value which we would like to replace it to (technicaly we pass it as null in the third parameter to Table.ReplaceValue() , but ignore in the body of the custom replacer function).
The output of the (x, y, z)=> funciton is assigned to the value in the target column (being Player IDs.IDFANGRAPHS).
If you set the step exactly as I wrote it, it should retun a list for each row in the Player IDs.IDFANGRAPHS field containing the {[value in the Player IDs.IDFANGRAPHS fireld], [value of the Index assosiated with this row], [null]}. If you alalyse the content of the lists for the rows that were failing you may find the problem.
Also, bear in mind that the error maybe in some other place as PBI uses "lazy" calcs, this step may be just a step where the problem surfaces itself, but not where it happens.
Cheers,
John
- coreych3 years agoRegular Visitor
Ok, I ran the code exactly as you typed it...
#"Replaced Value" = Table.ReplaceValue(#"Removed Columns", each [Index], null, (x,y,z)=> {x, y, z}, {"Player IDs.IDFANGRAPHS"})This code ran error free, but it does not appear to have done anything. I'm looking at my table exactly as it was, and player 296 still has the same fangraphs ID as player 297, that incorrect fangraphs ID is 27646 showing for both of them instead of 16942 for player 296 and 27646 for player 297.
- jbwtp3 years agoMemorable Member
Hi coreych,
the idea was that you will be able to check the parameters that are passed to the replacer funciton. If you can see the "ordinary" values in the Player IDs.IDFANGRAPHS column after executing this step, something clearly went wrong as it supposed to contant lists (containing the parameters passed to the replacer function), not text or numbers.
From this parameters you were expected to be able to see what exactly the filter needs to be.
Cheers,
John