I would like to replace the numbers in the 'Product' column with text values.
Como posso editar um DataSet?
I would like to replace the numbers in the 'Product' column with text values.
Como posso editar um DataSet?
Consider creating a constant dictionary of codes versus names in a project script module. Something like this:
productNames = {1: 'Something',
2: 'Something Else',
63: 'Chocolate',
100: 'Vanilla'}
Then use it in your view()
expression like so:
view("SELECT scriptModule.productNames.get(Producto, 'Unknown') As Producto, Volume WHERE Volume != 0", {value})
It can be tricky to group on a column that you are replacing, but should succumb to a bit of experimentation.
Thanks! Worked perfectly.
I would like to group the 'Products' and add the 'Volumes', I'm trying with 'GROUP BY', but without success.
I tried like this too:
view("SELECT ROW_NUMBER() OVER(GROUP BY Produto ASC) AS 'Id', Informacoes_Producao.ListaProdutos_BD.listaProdutos_BD(Produto) AS 'Produto', sum(Volume) AS 'Volume' WHERE Volume != 0 GROUP BY 'Id' ", {value})
Just need to group now
You cannot use any SQL expressions in my view()
function's PseudoSQL. It uses python expressions. You would use Group By Producto
similar to what you did first. You might need to have your dictionary lookup produce a different output column name so the result is unambiguous.