Substring in Calc script Essbase - oracle

I am trying to get the First 3 characters from Accounts dimension in Essbase (BSO cube). When i try to execute the below query. I am getting an error "Invalid Object type"
FIX(
#substring(#NAME("Account"),0,3),
"Jan"
)
ENDFIX

What are you trying to obtain?
In the FIX section you should only write the cross-members for the calc
like
FIX("Jan", "FY20", "Actual")
/*In this section you can include the code*/
#CONCATENATE("Item_",#substring(#NAME("Account"),0,3))
ENDFIX

Related

How can I use 'update where' select in FoxPro?

I am totally new to FoxPro (and quite fluent with MySQL).
I am trying to execute this query in FoxPro:
update expertcorr_memoinv.dbf set 'Memo' = (select 'Memo' from expertcorr_memoinv.dbf WHERE Keymemo='10045223') WHERE Keydoc like "UBOA"
I got the error:
function name is missing )
How can I fix it?
In FoxPro SQL statements you would not 'single-quote' column names. In Visual FoxPro version 9 the following sequence would run without errors:
CREATE TABLE expertcorr_memoinv (keydoc Char(20), keymemo M, Memo M)
Update expertcorr_memoinv.dbf set Memo = (select Memo from expertcorr_memoinv.dbf WHERE Keymemo='10045223') WHERE Keydoc like "UBOA"
If you would provide a few sample data and an expected result, we could see whether the line you posted would do what you want after correcting the single-quoted 'Memo' names.
NB 1: "Memo" is a reserved word in FoxPro.
NB 2: As you know, the ";" semicolon is a line-continuation in Visual FoxPro, so that a longer SQL statement can be full; of; those;
So that the Update one-liner could be written as:
Update expertcorr_memoinv ;
Set Memo = (Select Memo From expertcorr_memoinv ;
WHERE Keymemo='10045223') ;
WHERE Keydoc Like "UBOA"
NB 3: Alternatively, you can SQL Update .... From... in Visual FoxPro, similar to the Microsoft SQL Server feature. See How do I UPDATE from a SELECT in SQL Server?
I would do that just as Stefan showed.
In VFP, you also have a chance to use non-SQL statements which make it easier to express yourself. From your code it feels like KeyMemo is a unique field:
* Get the Memo value into an array
* where KeyMemo = '10045223'
* or use that as a variable also
local lcKey
lcKey = '10045223'
Select Memo From expertcorr_memoinv ;
WHERE Keymemo=m.lcKey ;
into array laMemo
* Update with that value
Update expertcorr_memoinv ;
Set Memo = laMemo[1] ;
WHERE Keydoc Like "UBOA"
This is only for divide & conquer strategy that one may find easier to follow. Other than that writing it with a single SQL is just fine.
PS: In VFP you don't use backticks at all.
Single quotes, double quotes and opening closing square brackets are not used as identifiers but all those three are used for string literals.
'This is a string literal'
"This is a string literal"
[This is a string literal]
"My name is John O'hara"
'We need 3.5" disk'
[Put 3.5" disk into John's computer]
There are subtle differences between them, which I think is an advanced topic and that you may never need to know.
Also [] is used for array indexer.
Any one of them could also be used for things like table name, alias name, file name ... (name expression) - still they are string literals, parentheses make it a name expression. ie:
select * from ('MyTable') ...
copy to ("c:\my folder\my file.txt") type delimited

how to write for loop and if statement to fill specific value

I'm trying to fill a new column in my data frame based on specific condition.
From column is already timedelta dtype.
for index in df:
if From >= "07:00:00" & From <"15:00:00"
df.shift="A"
I get a syntax error.
My dataframe looks like this (inferred from comment):
From,shift
00:00:00,None
00:30:00,None
01:00:00,None
01:30:00,None
02:00:00,None
[...]
Try adding ":" to the end of the "if" statement. It is missing in your example.

exctract substring from a large string under certain conditions in painless

In painless I would like to create a script which reads a keyword field called 'objldn' and extracts only five consecutive characters sometimes present in a precise position. Infact, in the keyword field 'objldn' there are a large variety of long strings among which there are some of them with a third underscore. After the third underscore, if it is present, I can fetch the consecutive 5 chars.
Whith the following lines of code I implement what I want:
def LU = doc['objldn'].value.splitOnToken('_');
return LU[3].substring(0, 5);
But the system returnes an error message "out of bounds":
Request error: array_index_out_of_bounds_exception, Index 3 out of
bounds for length 3 in "def LU =
doc['objldn'].value.splitOnToken('_'); ..." (Painless script)
error executing runtime field or scripted field on index pattern
return LU[3].substring(0, 5);
^---- HERE
may be it is due to the fact that many strings do not have the third underscore or do not even have one and therefore I need to implement firstly a IF statement which evaluates if a third underscore is in the string and only if it is present it proceeds to execute splitOnToken()... but I am not able to do it correctly. Can you help me to add the IF statement in the script please?
Why not simply checking the length of the LU array?
def LU = doc['objldn'].value.splitOnToken('_');
return LU.length >= 4 ? LU[3].substring(0, 5) : null;

Error: BC30201 IN ssrs

I'm getting
The value expression for the text run
'PAYEE_NAME.Paragraphs[0].Textruns[0]' contains an error BC30201" for:
=iif(isnothing(First(Fields!PAYEE_NAME.Value, "AddressDetails")),"",(First(Fields!PAYEE_NAME.Value, "AddressDetails")+vbcrlf))+
iif(isnothing(First(Fields!ADDRESSLINE1.Value, "AddressDetails")),"",(First(Fields!ADDRESSLINE1.Value, "AddressDetails")))
But not for:
=replace(iif(isnothing(First(Fields!PAYEE_NAME.Value, "AddressDetails")),"",(First(Fields!PAYEE_NAME.Value, "AddressDetails")+vbcrlf))+
iif(isnothing(First(Fields!ADDRESSLINE1.Value, "AddressDetails")),"",(First(Fields!ADDRESSLINE1.Value, "AddressDetails")))
," ","")
why? How do I solve this? The second expression removes spaces between words and I don't need that. I want it as, if there is payee name for a payee then display it, If not go to 2nd line and do the same.

How to use AND & OR in powerquery Fromulas?

I want to use Power Query Text.Contains function to check if the text contains one of my specified values.
Example:
If Text.Contains([#"My Columns"], ("a" OR "b" OR "c")) Then "Found" Else "Not Found"
I've already tested syntax like:
Text.Contains([#"My Columns"], {"a","b","c"})
Text.Contains([#"My Columns"], ("a"||"b"||"c"))
But I got error message, does anybody know how can I use AND & OR in Power Query's Formulas?
I would use Text.PositionOfAny, something like:
if Text.PositionOfAny( [My Columns] , { "a", "b" , "c" } ) = -1 then "Not Found" else "Found"
Note PQ formulas are (irritatingly) case sensitive so "if" "then" and "else" must be lower case, and the function name must be mixed case exactly as above.
The above code assumes you have a single column named "My Columns". If you actually want to search across multiple columns, then just add a "Merge Columns" step upstream (from the Add Column ribbon).

Resources