Hello, is it possible to cast a column that contains real values (ex: 1.01, 1.04, etc.) and NaN values, as a numerical column ?
My end goal is to be able to build custom columns when asking questions with metabase on this column.
Example:
To create column C = A + B, I need A and B to be of a numerical type.
(I know I could do it with sql CAST(A as FLOAT), but I want it to be doable from the ‘ask a question’ option.
Thanks all for your help
Hi @MichaelU
I don’t quite understand what you’re trying to do, but Metabase doesn’t have a cast function in Custom Expressions, but real is like decimal, so you should be able to add those together without any problems.
Hi @flamber, thanks for the answer.
For more clarity:
I have one column that contains NaN’s, and for that reason, even when I specify that this column is of type numerical from the administrator menu, it is considered as text when I try to use it in custom columns.
I want to be able to perform standard numerical operations on this column, but I get an error that says I cannot add a column float with on of type text.
@MichaelU Please post “Diagnostic Info” from Admin > Troubleshooting, and which database you’re using.
And depending on the database, run this query on your table too:
I just updated to version v0.36.5.1 yesterday, maybe it's related to that. I will go back to an earlier version and look again at troubleshooting infos.
@MichaelU I think you’re misunderstanding. The application database is where Metabase keeps all it’s information - by default it’s H2, which shouldn’t be used in production.
Indeed, I see what you mean here thx !
Do you think this is the cause of my problem ?
For reminder :
Because there are null values in a column, the column is not treated as a numerical one but as text.
@MichaelU No, but H2 can easily become corrupted and doesn’t handle the same load as Postgres.
null shouldn’t be a problem since 0.36 (or perhaps it was 0.35), but I have a feeling that the field is incorrectly fingerprinted. Please see the other forum topic I linked to before.
Otherwise please provide a sample of your schema and data, so I can try to reproduce.