Pentaho Spoon:How to modify all the values of a column? - pentaho-spoon

I am new to Pentaho spoon and even after a long time of research, didn't resolve my problem:
I have a table, and want to multiply by 3 all the values of few columns.
For instance, if I have inside of a column (5, 10, 3) then it becomes (15, 30, 9).
I don't want to have a new field if it's possible, just want to replace those values.
The calculator option requires an another field and I only need one constant. Tried with Modified javaScript value, it just sets everything to zero. Can anyone help me?
Thanks!!

You can use the Formula step to override / replace a value from an existing column. Keep in mind that for this to work, the Value Type's of both the origin and target columns must match, INT/INT, String/String and so on.

Related

In PostgreSQL, is it possible to have a default format for real columns?

In PostgreSQL, I have a column with people's height in meters. If the height is, say 1.75 m, it shows properly, but if the height is 1.70 m, it shows as 1.7. I would like to have this already formatted to two decimal places, showing as 1.70 without formatting in each and every SQL call. Can I specify this in the table creation? Or a stored procedure, or something? I've seen a few things about timestamps, but not for real fields. Knowing how to format the decimal point as a colon (1,70) would be a plus.
Basically, presentation and "cosmetics" are the job of the application, not the database.
Having a default number of decimal places for floats would also create a problem, because the data returned by the database would not be the actual data in the column. So if you did a SELECT and it returned a value of 1.75, then if you searched for this value, you might not find it because the actual value stored was not 1.75 but 1.7499999999 and it was only rounded for display.
Potential solutions:
If you want to store a specified number of digits, use NUMERIC. This will solve the 1.7499999999 problem above. If you use NUMERIC, when doing a SELECT you get the actual contents of the column.
In your app, if you use an ORM, use a Decimal (or similar) type for the column with the appropriate settings so it displays the way you want.
Or create a view with the format applied to the column, but in this case if you want the trailing zero, the type will be text and not float, and it will not be searchable unless you create an extra index on it.
Generated column with the number formatted as you want, maybe easier than a view

How to run Logical Test in Tableau when one column has multiple rows

The first column only has one row while the second column has three rows that correspond to the first row of the first column. For exemple, something like this.
Is there a way to run a logical test where if any of the values in the second column pass the test, I get a 1 and if none of the values in the second column pass the test, I get a 0.
Thank you for your help!
Yes, you can do this, using LODs and simple boolean formula. Please give a more specific example of what you want to do and you can have a formula that'll do it.

Tableau calculated field that refers to its own previous lagged (-1) value to calculate

I need help on a basic calculation that I'm unable to figure on Tableau.
I am trying to setup a calculated field that has dependency on its previous value to calculate its current value. Here is a simple example from Excel -
Sample Exhibit
As you can see, each value in a row is dependent on its previous value and multiplied by a constant.
In Tableau, when I'm trying to create a calculated field, it is not letting me refer to itself (-1 lagged value) in the code. I'd appreciate any help on how this can be resolved. Thanks in advance!
Tableau can do this client side with a table calc. You’ll have to learn how table calcs operate from the help- especially partitioning and addressing. Then you can use the function Previous_Value() to refer to the previous value. Practice on something simple first to make sure you understand how previous value() works. Hint, the argument to that function doesn’t mean what most people assume it means
If you want to perform this calculation server side instead, then you’ll need to use custom SQL so you can specify an analytic aka windowing query
Check the LOOKUP field to get the value from the preceding row. For example: LOOKUP(SUM([Value]),-1)
https://help.tableau.com/current/pro/desktop/en-us/functions_functions_tablecalculation.htm#lookupexpression-offset
You may need to make yourself familiar with the Table Calculation partitioning if not getting the expected result.

Microstrategy - AddDays

I need to be able to use the AddDays function to derive the last week from the date column that I have in the dataset.
So, I have delivery_date of 3/21/2018, then I want to derive AddDays('3/21/2018',-7.0) - only that I want to do do this for every row in the dataset. But, the AddDays function only takes a metric. Can you suggest how I can work around this situation?
Thank you in advance,
Abhilash
As usual it depends on what you want to achieve.
If you need an attribute that returns delivery_date - 7, just create a new attribute and in the definition of the expression you can put a formula like [delivery_date] - 7 or use a pass-through function like ApplySimple to write the formula for your database (more info here).
Note: If you do this, you need to do the form expression with the formula (or the ApplySimple) only for the forms mapped on the fact table, the forms mapped on the lookup table (your Day dimension table) should be without formula, otherwise parent level will returns wrong values. Also if you don't a lookup for this new attribute create an alias or enable -Attribute Role Recognization more here.
If you need to calculate metric values for delivery_date - 7, then in that case you need to use a transformation metric. You will need to create a minus 7 days or same day previous week transformation, then associate it to the Delivery Date attribute and create the needed metrics. The last week transformation is included in the MicroStrategy Tutorial project.

Setting add-calc-column() values for each browse row?

With static browses, on a ROW-DISPLAY I would calculate variables that are columns on a static browse. However, with ADD-CALC-COLUMN() how do I for each row in a browse go about setting that columns value? Thanks.
A Calculated column cannot really calculate values for you. The name is a bit misleading, to my opinion. You need to use a ROW-DISPLAY trigger to calculate the values yourself and display them in the right column. You may also have to REFRESH the browse in order to activate the trigger on all 'calculated' columns.