Once I have an existing table in QuestDB, is there any way to check if the table has a designated timestamp and if yes, which column is it?
This is possible as of version 6.0 using tables() and table_columns(). The following is an example which returns the schema of a table, including which column is set as a designated timestamp:
table_columns('my_table')
column
type
indexed
indexBlockCapacity
symbolCached
symbolCapacity
designated
symb
SYMBOL
true
1048576
false
256
false
price
DOUBLE
false
0
false
0
false
ts
TIMESTAMP
false
0
false
0
true
s
STRING
false
0
false
0
false
For more information, see the documentation for table meta functions
There is no way as of 5.0.6 I believe. This is definitely a missing feature.
Related
I have created four calculated columns that give True or False for a unique property ref in each row, based on the presence of a registered contact (CMS) on a list (Tele Open, Tele Closed, Written Open, Written Closed). I now need to assign a status to each property ref based on the combination of True False.
I am able to do this using a multiple nested IF AND statement in Excel but am confused about to do this in Power BI.
I haven't yet attempted to do this and need some advice on how to frame the statement, as I am not familiar enough with M Language.
'''
If -- ALL are FALSE = Not Yet Investigated
If -- Tele Open is TRUE = In Progress
If -- Tele Open is FALSE AND Tele Closed is FALSE AND Written Open AND/OR Written Closed is True = In Progress
If -- Tele Open is FALSE AND Tele Closed is TRUE = Closed
'''
The various combination of True False in the categories listed above will produce a Not Yet Investigated, In Progress or Closed status as above.
The basic syntax for a calculated column with an IF statement is
column = if [something] > 1 then [something] else [something else]
you can then nest statement using and and or
column = if [something] >= 1 and [something] <= 10
then "Low"
else if [something] >= 10 and [something] <= 20
then "medium"
else "high"
Hope that helps
I have two columns.
One has a numeric value and another has a range.
I need to match the value from the first column to the range on the second column and return a true or false in a third column.
I'm assuming I'd need to use the IFS function, but not entirely sure how.
The ranges column has the following ranges:
1-15, 15-30, 30-50, 50+
The value column would just have a number.
I've tried messing around with the IFS function:
=IFS((D2<=15, e2="1-15", true, false), (d2<=30, e2="15-30", true, false), (d2<=50, e2="30-50", true, false))
Basically, I want it to be:
Column 1 Column 2 Column 3
1 1-15 TRUE
16 1-15 FALSE
54 30-50 FALSE
It looks to me as though you might as well split the end points of the ranges:
=and(A2>=1*left(B2,find("-",B2)-1),A2<=1*mid(B2,find("-",B2)+1,len(B2)))
Assuming 1 is in A2,
=ARRAYFORMULA(IF(LEN(A1:A),
IF((A1:A >= 1*IFERROR(REGEXEXTRACT(B1:B, "\d+")))*
(IF(IFERROR(REGEXMATCH(B1:B, "\+$")), A1:A < 999^99,
A1:A < 1*IFERROR(REGEXEXTRACT(B1:B, "-(\d+)")))), TRUE), ))
Im very confused why the first 3 arnt all correct. As isn't true a keyword, it of course is a Boolean literal and is interchangeable with 1?
True and False are not keywords, they are boolean values because they are associated with 1 and 0 respectively. For a complete list of keywords see Is it possible to get a list of keywords in Python?
In Power BI I have an M Query that tests for the value in a column equaling or not equaling to null.
When I add the statement for [Sale.Revenue] <> null I get an error however it works fine for the [UserRole.Name] = null it works fine. Tested just by removing the statement and adding it back.
We cannot convert the value null to type Logical.
This seems like it should work but just can't figure it out.
add_user_role_group = Table.AddColumn(
join_expand_sale,
"UserRole.Group1",
each (
if [UserRole.Name] = null and
[Sale.Revenue] <> null then
"Group1"
else if Text.Contains([UserRole.Name], "Manager") then
"Group2"
else
"Undefined"
)
)
I am sure it is something glaringly obvious :/ Thanks for your thoughts on this.
One of your rows has a null value for both UserRole.Name and Sale.Revenue. You need to check for that explicitly, and then add it to the "Undefined" group.
What happened is that the first condition fails because Sale.Revenue is null. The second condition calls Text.Contains, which returns null when [UserRole.Name] is null (Text.Contains returns a nullable logical value). null is not true or false, so you get the error.
After a such journey, finaly I found Text.Length !!
You can solve your problem like this:
if Text.Length([UserRole.Name]) = 0 and
Text.Length([Sale.Revenue]) > 0 then
I hope I have helped you.
Reference: Power Query M - Text.Length
Your issue is in the Text.Contains formula. You create an if statement that expects an expression that returns either true or false.
When the Text.Contains formula contains a null value, it returns 'null' as answer, and not true or false. You can adjust your code:
Text.Contains([UserRole.Name], "Manager")
To
Text.Contains([UserRole.Name]??"", "Manager")
The ?? is the COALESCE operator. In case it finds a null value, it now treats it as "". Instead of returning null it now returns true or false.
More on text functions in this article: https://gorilla.bi/power-query/text-functions/
Enjoy Power Query,
Rick
I'm currently trying to validate if a string is exactly true or false as I'm building a spreadsheet importer using CF10.
My users will either enter in one of the following.
NULL, which will equate to false
TRUE which obviously equates to true
FALSE which again will equate to false.
I'm trying to use the isValid('boolean',variable.data) to validate if the data is in fact a boolean string or not. However after reading quite a few posts I can see that it will validate true if its a positive number and false if it is a negative one etc.
I'm wondering if anyone has an easy fix to getting boolean validation working for strings easily ? Is this more a regular expressions scenario to make it work properly ?
Any help greatly appreciated.
Assuming you mean the literal string "NULL", one option is using list functions. Search a list of allowed values, ie "true,false,null". If the entry is found, it is valid:
<cfif listFindNoCase("true,false,null", theValue)>
this is a valid boolean value
<cfelse>
not found. do something here...
</cfif>
Then a simple string comparison would return false for everything other than the literal string "true":
isTrue = compareNoCase(e, "true") eq 0 ? true : false`
If you need to evaluate whether a string is exactly "true" or "false", then you are not doing a boolean comparison, you are doing a string comparison.
So to that end, you'd be wanting to use compare() or compareNoCase() (depending on how rigid you need to be).
You could just do some logic or am I missing something.
<cfset booleanResult = enteredValue eq 'TRUE' ? true : false />