Calculating database cell value - mariadb

My issue is to calculate the division of one column and another column and to return it to new column in the database.
So each one of the cell in one column should be divided with cell that is next to her in other column.
How can I do that?
So in this picture every element of column "izmerenavrednost" and every element of column "ciljanavrednost" should give element in column "ocenavrednosti"
column"izmerenavrednost"/ column"ciljanavrednost"=column"ocenavrednost"

This would help
Update table
set ocenavrednost = ifnull(izmerenavrednost ,0.00)/ ifnull( ciljanavrednost ),0.00)

If I understand correctly, this is what you are after?
UPDATE table
SET ocenavrednost = izmerenavrednost / ciljanavrednost
If you wanted to subtract instead, then it would be this query:
UPDATE table
SET ocenavrednost = izmerenavrednost - ciljanavrednost

Related

Align Text To Row Identified by Number and to ID Matching that Embedded in String

I need to align text in an ALERT STRING column with the row identified by number in an ID ROW column.
Additionally, I need to also align the same ALERT STRING text with the same ID ROW number AND with the ID matching that embedded in a string in the TEXT WITH ID column. (This double-check will sometimes be necessary with the real-world data.)
So far, I've only figured out how to align the ALERT STRING with the ID matching that embedded in the TEXT WITH ID column:
=LOOKUP(2,1/SEARCH(A2,$F$2:$F$11),$G$2:$G$11)
I appreciate any help folks can offer. You can find an editable copy of the workbook here:
https://1drv.ms/x/s!ArQ7Kw6ayNMY2zktTW3pDCbMmJZ_
UPDATE: Nayan provided a solution to the first part of this question (please see answer below). I'm still trying to work out a formula for the column D part of this question, in which the row reference shown in column E is combined with a match of the ID shown in column A with its corresponding value in one of the text strings in column F.
The best I've been able to come up with so far is a formula with a high failure rate:
=INDEX($G$2:$G$11,MATCH(ROW(D2),$E$2:$E$11,MATCH("*"&A2&"*",$F$2:$F$11,0)))
Any help with this part of the question will be greatly appreciated.
ROW([reference])
Returns the row number of a reference
E.g.: Row(B2) returns 2. If nothing provided like ROW() will also
return row number based on position of cell where it is called.
VLOOKUP(loolup_value, table_array, col_index_num, [range_lookup])
Looks for a value in the leftmost column of a table, and then returns a value in the same row from a column you specify (col_index_num)
By default - the table must be sorted in an ascending order.
Try this:
=VLOOKUP(ROW(B2),$E$2:$G$11,3,FALSE)
INDEX(array, row_num, [column_num]) INDEX(reference, row_num,
[column_num], [area_num])
Returns a value or reference of the cell at the intersection of a particular row and column, in a given range.
In this case, you have to get row_num with MATCH function.
MATCH(lookup_value, lookup_array, [match_type])
Returns a relative position of an item in an array that matches a specified value in a specified order.
match_type: 1 (Less than), 0 (Exact match), -1 (Greater than)
Try this:
=INDEX($G$2:$G$11,MATCH(ROW(B2),$E$2:$E$11,0))
Identity Data with Multiple Criteria Condition using MATCH()
=INDEX($G$2:$G$11,MATCH(1, (ROW(D2) = $E$2:$E$11) * (ISNUMBER(SEARCH(A2, $F$2:$F$11))),0))
References:
https://exceljet.net/excel-functions/excel-vlookup-function
https://exceljet.net/excel-functions/excel-index-function
https://exceljet.net/formula/index-and-match-with-multiple-criteria
This is the formula I was looking for in column D:
=INDEX($G$2:$G$11,MATCH(ROW(D2)&"*"&A2&"*",INDEX($E$2:$E$11&$F$2:$F$11,),0))
You can see it working here.
Nayan provided a great deal of help with answering this question, so I will mark his answer as the accepted solution.
Syeda Fahima Nazreen provided the example I referenced to figure out the formula shown above.
Reference:
Nested Excel Formula with Two INDEX Functions and a MATCH Function with Multiple Criteria

Select one row in R, result is a new table

I try to select just one row in my data but the result come out in new data and I can't compute the mean of this, because the header is showing. But when I select the column, there is no problem and I can see the result as a value. You can see the result of the code in the photo that y is in data and X is in the value.
y=mydata[1,]
X=mydata[,4]
enter image description here
you should use rowMeans.
When you select a row you are selecting multiple variables and that results in giving you a dataframe.

BIRT report: dynamically adding columns to a table based on dataset data

In my report, a table is displaying results from a dataset and it has 6 columns.
But sometimes the dataset returns more than 6 columns depending on the report parameters.
So I need a way to dynamically add columns to my table
Thanks
I'd do it the other way round.
The number of the columns in the query is fixed anyway (for example: FIXED_A, FIXED_B, DYNCOL01, ..., DYNCOL20).
In the layout, your table should have columns for all columns (FIXED_A to DYN_COL20).
Clear the table's width. Set a fixed width for the fixed columns (with enough room left for the dynamic columns). Clear the width of all dynamic columns.
From now on, do not resize and column with the mouse, because this would set individual widths for each column again.
In your table properties, add aggregate bindings for each DYN_COLnn using the MAXIMUM function (let's call these MAX_COL01, ..., MAX_COL20).
For each columns, use a visibility expression like this (the number matching the layout column to the query column accordingly), e.g. for the first dynamic column:
!!row["MAX_COL01"]]
The !! means basically: interprete this as boolean, so the result is: show this column only if MAX_COL01 is not null - or in other words: if DYN_COL1 is not empty in any of the rows.

Not able to add new column to datable from computing other column values

I am trying to add column to datatable whose value is derived from some mathematical computations on other columns. I am doing as below:
dt.Columns.Add("OpeningBalance", GetType(Decimal), "Amt01-" + "Amt02-amt03")
What I need is to subtract amt03 to Amt02 and get absolute value of that. And then subtract that value from Amt01 and get result as non-negative(getting absolute.
I tried using Math.abs, but I am not sure how to exactly embed that inside this.
It should be like this :
math.abs (Amt01 - math.abs(Amt02-amt03))

Expression to Exclude rows that have a specific column blank

I want to exclude entire rows that have blanks for a specific column....I dont want to show a row that has the first name column as a blank...I was thinking maybe a case statement would help with this
case when [First Name] = blank then exclude???
If this is SQL, in general you could do this:
SELECT *
FROM myTable
WHERE myCol IS NOT NULL
I had to add a calculated column that would be used as a flag, and then filter on the flag.
if(Len([First Name])>0,1,0)
Now I am able to filter on the calculated column to show only rows that have 1 in it (which will be the rows where First Name is not empty).
This doesn't delete the row from the dataset, but has the same effect in visualizations as if it had been.

Resources