cancel
Showing results for 
Search instead for 
Did you mean: 

Session variables and data types ( can I force a data type? )

RADSr
Captain
Captain

I have a date dimension within which I have a sequence number.  It's an integer and I want it to be an integer so ... good so far.

RADSr_0-1658413582541.png

I also have a session variable defined

RADSr_1-1658413870398.png

 

but when I got use that session variable in an insight formula I get a message that I can't compare an int ( week_seq  in the insight ) to a string ( presumably the variable value ).      

Now *that* is probably a bug and I'll get to logging that w/ support, but in the interim is there any way to force a session variable to a specific data type?   

Wrapping the field in  int() in the session variable query does *not* work, but the variable reference in int() in the insight formula does. 

== snip ===

case(
        Date_US.Date_US.week_seq = int(
            $CurrentWeekSeq
        ), 
== end snip ===

 

 So I have some workaround, but I'll need to type that workaround everywhere I want to use this logic which would be great if we charged by character count, but as I do not ( even in wordy Community posts such as this ) it is, in reality, an annoyance.    

What I'd really like to do is make sure the session variable is treated as the proper data type by defining it as such.

-- IncortaOne@PMsquare.com --
4 REPLIES 4

DustinB
Employee
Employee

Hi Randy,

User-defined session variables are strings and we do not yet support returning any other type, so you are already following the best practice of casting the session variable to the desired type in your formula. Please refer to the knowledge base for variables. Supporting data type in session variables would be a great enhancement, please feel free to suggest in the product ideas. This will get a lot of votes (including mine)!

Prince
Employee
Employee

If you are using this variable in analytics (Business Schema & Dashboards), then you should also start using Global Variables, which is the recommended practice if you are not depending on the logged in user session.

Global Variables are dynamic and detects the data types according to the columns and functions used.

 

Session variables are re-evaluated with each session and it is cached per user, while global variables are not. You can refer to this article for more details.

@Prince 

I just did a quick test ( and looked at the documentation ) and it seems global variables can't be used in insight titles?    When I type:   "As of $$SV_Yesterday"  I see displayed "As of 7/21/22"  but when I type: "As of $$GV_Yesterday"  I see displayed "As of GV_Yesterday"

Am I missing something or add to the list for product ideas?   ( probably at least 50/50 I'm missing something 😉  ) 

 

-- IncortaOne@PMsquare.com --

Global variables are currently not supported in insight titles. The list of supported use cases for Global variables can be referenced here.