Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
QSMACHBI
Contributor III
Contributor III

Issue with variable in set expression - Qlik sense

Hi ,

I need your help guys,

I have a variable named : vIsPreviousPeriode

When I use this variable in a set expression to feed a column in a table objet, I don't get the good result ! (all the time 0 value !!!)


1. First I calculate the vIsPreviousPeriode

2. I use this syntax : =SUM({$<Myfield = {$(=vIsPreviousPeriode)}>} Mymeasure)

15 Replies
sunny_talwar

What is Myfield? and how do you define your variable?

QSMACHBI
Contributor III
Contributor III
Author

When I write the value's string for testing, iI have athe right response :

=SUM({$<Myfield = {"JUN-17"}>} Mymeasure) ===> Ok.

=SUM({$<Myfield = {$(=vIsPreviousPeriode)}>} Mymeasure) ===> 0 (wrong)!

QSMACHBI
Contributor III
Contributor III
Author

MyField is a field in my logical table

QSMACHBI
Contributor III
Contributor III
Author

vIsPreviousPeriode is a variable defined in varibales Editor (Qlik Sense)

sunny_talwar

Is MyField read as a date field by QlikView or Qlik Sense  (whichever you are using)?

QSMACHBI
Contributor III
Contributor III
Author

MyField is a string (Qlik Sense)

sunny_talwar

How do you create this in the script?

vIsPreviousPeriode

QSMACHBI
Contributor III
Contributor III
Author

The varibale is declared in the Qlik expression -variables (User interface) not in the Load editor

The variable «vIsPreviousPeriode» is delared like that :

$(vIsCurrentMonthPeriode)&'-'&Right($(vIsPreviousYear),2)

vIsPreviousPeriode will store values like these : JUN-17 ; JUL-17 ; REG-16;...

sunny_talwar

Try this

=Sum({$<Myfield = {"$(=vIsPreviousPeriode)"}>} Mymeasure)