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

Last 4 weeks variable issue

Hi all,

I'm trying to use a "last 4 weeks" variable but i'm encoutering issues with syntax I think.

I've tried this :

num(SUM({<[WeekNumber]={">$(=$(vMaxYearWeekID)-4)<=$(=$(vMaxYearWeekID))"}>}[Invent.Qty]))

My MaxYearWeekID variable looks like this :

=max( {1} YearWeekId)

What am I doing wrong?

Thank you in advance for the help.

Best regards,

1 Solution

Accepted Solutions
benoitgochel
Contributor III
Contributor III
Author

The problem was somewhere else in my master calendar.

It is solved now.

Thank you for you time youssefbelloum

View solution in original post

7 Replies
YoussefBelloum
Champion
Champion

Hi,

the approach is ok, variable ok, expression ok, what do you see on the chart ?

benoitgochel
Contributor III
Contributor III
Author

The value displayed is 0.

But when I put the "YearWeekID" field in a filter pane and select the last 4 weeks, I get a good value.

YoussefBelloum
Champion
Champion

do you have all the weeks on your data ?

example:

Measure, Week

100,1

200,2

120,3

210,4

340,5

145,6

125,7

574,8

195,9

354,10

165,11

==> here all weeks are available, you will see 4 lines as expected on the graph

or yo don't have all the weeks, like this:

Measure, Week

100,1

200,2

120,3

210,4

340,5

145,6

276,7

310,9

174,11

==> here week 8 and week 10 are missing.. so using your expression, you will only see two lines on the graph

benoitgochel
Contributor III
Contributor III
Author

I do have all the weeks, numbers from 1 to 813.

And when I pick manualy the weeks 813 - 812 - 811 - 810, I see a result in my KPI.

Screenshot_1.png

With production KPI like :

num(SUM([Invent.Qty]))

YoussefBelloum
Champion
Champion

Would you be able to share sample app the see the issue ?

benoitgochel
Contributor III
Contributor III
Author

The problem was somewhere else in my master calendar.

It is solved now.

Thank you for you time youssefbelloum

YoussefBelloum
Champion
Champion

no problem, good luck