How to handle if one column value is null then use another column value in freemarker - freemarker

For suppose i have two columns drillTime and drillDateTime.
Condition:
If drillTime value is there print drillTime or if it is null print drillDateTime.
Our Code:[#if dmd.drillTime??]${dmd.drillTime!""}[#elseif dmd.drillDateTime??]${dmd.drillDateTime!""}

Here's shorter solution:
${dmd.drillTime!dmd.drillDateTime!}

Related

How do I identify whether a column entry starts with a letter or a number using m code in power query?

I have a column that contains either letters or numbers. I want to add a column identifying whether each cell contains a letter or a number. The problem is that there are thousands of records in this particular database.
I tried the following syntax:
= Table.AddColumn(Source, "Column2", each if [Column1] is number then "Number" else "Letters")
My problem is that when I enter this, it returns everything as "Letter" because it looks at the column type instead of the actual value in the cell. This remains the case even when I change the column type from Text to General. Either way, it still produces "Letter" as it automatically assigns text as the data type since the column contains both text and numbers.
Use this expression:
= Table.AddColumn(Source, "Column2", each if List.Contains({"0".."9"}, Text.Start([Column1], 1)) then "Numbers" else "Letters")
Note: It would have been smart to add sample data to your question so I wouldn't have to guess what your data actually looks like!
Add column, custom column with
= try if Value.Is(Number.From([Column1]), type number) then "number" else "not" otherwise "not"
Peter's method works if the choice is AAA/111 but this one tests for A11 and 1BC as well

How to pass contant string value for a column in SUMMARIZECOLUMN

I want to pass a constant string value i.e. Not Applicable for one of the column values that will be used in SUMMARIZECOLUMNS function. But I am not find any format in how to do the same.
SUMMARIZECOLUMNS( table_name[column_name], "Custom_Column_Name", "Not Applicable")

NIFI: Unable to extract two values from a list during each iteration over a loop

I would like to retrieve large SQL dump between date ranges. For the same, I constructed a loop over a date list, which intends to extract adjacent fields. Unfortunately, in my case, it doesnt work as planned.
Following is my flow:
Replace Text: Takes flowfile content date list as all_first_dates
Initialize Count:
While Loop:
Get first and adjacent dates:
However, on seeing the queue, I get the first and second as this:
Whereas, I desired as 2016-01-01 and 2016-01-02 for first and second respectively on my first iteration and so on.
check the description of the getDelimitedField function and it's parameters:
Description: Parses the Subject as a delimited line of text and returns just a single field from that delimited text.
Arguments:
index: The index of the field to return. A value of 1 will return the first field, a value of 2 will return the second field, and so on.
delimiter: Optional argument that provides the character to use as a field separator. If not specified, a comma will be used. This value must be exactly 1 character.
...
you are not passing the second parameter, so the coma used to split the subject, and you got the whole subject as one element in result.

Filtering Value or Blank in Google Sheets

I would like to filter a specific value as well as blank values.
Example: Filter if the value is "VALUE" or ""
I tried this:
=filter({Summation!E2:K},match(Summation!D2:D,{$B$1,""},false))
And also tried this:
=filter({Summation!E2:K},or(match(Summation!D2:D,{$B$1},false),isblank(Summation!D2:D)))
But non of these work. How do I match for blank values. I want all blank values as well as those with the value B1.
You could use something like =QUERY(B1:K,"Select * where B='' and B='VALUE'",0)
That selects all data in the range B1:K where column B is blank (B='') AND where B is equal to VALUE (B='VALUE').
Replace B with whatever column contains the value you're trying to find.

Replace NULL using a function

Is there any function to replace NULL or empty space with special character in hive? when I execute the below statement it returns a semantic exception stating trim works only on string/nvarchar
CASE
WHEN TRIM(q.address) = '' OR q.address IS NULL THEN '?'
ELSE q.address END as address
Please help.
Use LENGTH() to check the length of the column value. It returns > 0, if there is some value else return 0 for empty or NULL value.
Also frame the column value in CASE WHEN ... END block
The final query may look like:
SELECT CASE WHEN LENGTH(address) > 0 THEN address ELSE '?' END AS address
FROM table_name;
Please refer Replace the empty or NULL value with specific value in HIVE query result
Hope this help you!!!
In order to replace nulls you can use Coalesce
Coalesce( q.address, '?')
But it seems your field adress is not of the proper type to use trim, can you show us the type of that field?

Resources