Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I am trying to create a Qlik Sense variable, to use in chart expressions, that stores the value of Last Year's Financial Year, based on This Year's Financial Year, which is calculated on the maximum possible Financial Year of Actual Data (as opposed to Budget Data).
All the Expressions that I list below WORK in QlikView and DO NOT WORK in Qlik Sense.
1) vMaxFinLastYr =YearName(Max({<isAct = {1}>}[Financial Year]), -1 ,7) // I use this expression when [Financial Year] is in the format "2023-2024" using YearName function in the script to create the [Financial Year] field.
2) vMaxFinLastYr =(Left(vMaxFinYr, 4) - 1) & '/' & (Right(vMaxFinYr, 4) -1) // I use this expression when [Financial Year] is in the format "2023/2024" NOT using YearName function in the script, but by creating a string type field by concatenating the 2 years together.
The first expression returns '-1' in Qlik Sense. The YearName function works in the Qlik Sense Variable Editor if I don't use the second parameter, but then it only returns values in the format "2023" not "2023-2034" so it doesn't work for the purposes of variables in chart expressions.
The second expression returns null in Qlik Sense and the issue seems to be the & '/' & part. I have also tried & "/" &.
Any ideas would be appreciated.
I got it to work in Qlik Sense by using the following expression in the Variable Editor
(Left($(vMaxFinYr), 4) - 1) & '-' & (Right($(vMaxFinYr), 4) - 1)
Note: there is no = in the expression, if I add = then the result is -1 ???
Nr. 1) heavily depends on whether your [Financial Year] field is containing numerical/date values or "2023-2024" as a string. Same goes for the variable. Do you want it as a formatted numerical value or a text?
In nr. 2) you are mixing string and numerical functions and operations. If you want to subtract 1 from "2023" ou need to vonvert it to a number first.
The expressions and field attributes are not the issue. It all works in QlikView. It doesn't work in Qlik Sense??
I got it to work in Qlik Sense by using the following expression in the Variable Editor
(Left($(vMaxFinYr), 4) - 1) & '-' & (Right($(vMaxFinYr), 4) - 1)
Note: there is no = in the expression, if I add = then the result is -1 ???