Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Variables enable great opportunities, however, I couldn't find them in Qlik Sense?
Yes you can. Here's an example of how I use them:
I created date variables in the data load editor:
// Set Month and Year Variables
LET vYearCurrent = Year(Today());
LET vYearPrevious = Year(YearStart(Today())-1);
LET vYearPreviousX2 = Year(YearStart(Today())-2);
LET vMonthCurrent = Month(Today());
LET vMonthPrevious = Month(MonthStart(Today())-1);
LET vMonthPreviousX2 = Month(MonthStart(Today())-2);
//*****************************************************
Then I use them with Set Analysis:
Sum({<[Year]={'$(vYearCurrent)'}>}[Spend])
That object will then only show spend for the value of my variable "vYearCurrent" which is of course in this case "2015".
Hope that helps! !
Hi Oktay - yes they exist - but through the use of the Data Load Editor only. You can also reference the variable when when defining a measure and dimension in the master library.
UPDATE: 6/22/2016 - they can NOW also be added in the variable editor interface, NOW part of Qlik Sense: Qlik Sense - Variables Interface (video) - ( updating this for those that come across it when browsing the forums. )
If you need an example please let me know.
Please mark the appropriate replies as helpful / correct so our team and other members know that your question(s) has been answered to your satisfaction.
Regards,
Mike
As Michael mentioned they do exists in Sense. Only way to define them is by using Load Script editor. There is no way you can define them through UI, like we can do it in qlikview. But i think this is in their road map to provide this in future.
Also one thing i have noticed, variables are not auto populating when you start typing them in UI. For example in a text box once you type equal sign "=" and start typing the variable name, usually it should populate the names like it does in qlikview. this is not happening in QS 1.0
Yes. As others have mentioned you must use the Data Load Editor to set those variables and unfortunately you cannot set variables with UiX, etc. But I use variables for things like 'Previous Year' and 'Current Year' setting those up at the time of data load. Then I can use those in Set Analysis with my visualizations, measures, etc.
Is it possible to define a variable with set analysis inside ex. SET Var1 = 'SUM( {< FIELD = {"0"} >} AMOUNT)' in data load editor ?
I'm trying to do it in several ways but it doesn't works!
Please guide me to the right path.
Many Thanks
Andrea
Yes you can. Here's an example of how I use them:
I created date variables in the data load editor:
// Set Month and Year Variables
LET vYearCurrent = Year(Today());
LET vYearPrevious = Year(YearStart(Today())-1);
LET vYearPreviousX2 = Year(YearStart(Today())-2);
LET vMonthCurrent = Month(Today());
LET vMonthPrevious = Month(MonthStart(Today())-1);
LET vMonthPreviousX2 = Month(MonthStart(Today())-2);
//*****************************************************
Then I use them with Set Analysis:
Sum({<[Year]={'$(vYearCurrent)'}>}[Spend])
That object will then only show spend for the value of my variable "vYearCurrent" which is of course in this case "2015".
Hope that helps! !
Hello,
I know I am kind of late, but I tried your approach and unfortunately I always get my result 0. Any ideas?
Do you have data that should respond to your calculation? You can also add the variable to a textbox to see if the variable was created and loaded the correct value.
Hi Michael,
Will the new version of Sense allow the import of externally defined variables directly, as Master Library Items?
I define all my measures in an excel file, complete with set analysis, etc. That has proved invaluable on projects. I know that these can be imported as variables (I do mine via a loop in script from the excel file), but was hoping that I would not have to add them one by one as Master Library Items.
Dave
Hi David - not that I know of, - however you can now create them with the variables interface in Qlik Sense, though they are not global, they are just part of that app.
HTH
Mike