Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Set analysis prb

Hello

I want to compare sales : week  Vs Week -1 and Week N Vs Week N -1

i use :

"=sum({$<Année = {$( =only(Année) - $(=if(only(Semaine) = 1, 1, 0)))}, Semaine = {$( =only(Semaine)-1 + $(=if(only(Semaine) = 1, 53, 0)))}>} CA_RAY)"

For Week Vs Week -1 nut result for all week it's 0 only for week 1 this work

but for Week N Vs N-1 it's work perfectly.

I need your help pls!

1 Solution

Accepted Solutions
swuehl
MVP
MVP

Hm, I don't completely understand.

Above expression is to give you the sum of CA_RAY for week prior to selected, is this true?

How do you calculate the expression for N vs N-1 then?

Please note that you may only select one value in the Annee resp. Semaine fields, because only will give you NULL if you select more than one value.

Could you post a small example app here? I think this would make things easier.

Stefan

View solution in original post

3 Replies
swuehl
MVP
MVP

Hm, I don't completely understand.

Above expression is to give you the sum of CA_RAY for week prior to selected, is this true?

How do you calculate the expression for N vs N-1 then?

Please note that you may only select one value in the Annee resp. Semaine fields, because only will give you NULL if you select more than one value.

Could you post a small example app here? I think this would make things easier.

Stefan

Not applicable
Author

Hello My probléme is resolved I used a fieled with If expression to select Année (Year) and Semaine ( Week)

So the function Only dont work .

Thanks for your help !

  • Expression for N Vs N-1 : sum({$<YearNumber = {$(=only(YearNumber) - 1)}>} SALES)

  • Expression for Week Vs Week -1 :

sum({$<YearNumber = {$( =only(YearNumber) - $(=if(only(WeekNumber) = 1, 1, 0)))}, WeekNumber = {$( =only(WeekNumber)-1 + $(=if(only(WeekNumber) = 1, 53, 0)))}>} Sales)

swuehl
MVP
MVP

I am glad that this was of any help for you.

Instead of Only() you could use max() function, which will also work if you select more than one (returning the max year for example), or limit the field selection in properties to always one selected value.

Regarding your Week vs Week-1 calculation, it might be easier if you calculate the week difference based on date (using eg weekstart() ), this should take year change into account. There is also a weekyear() function to calculate the year a week is in.

Regards,

Stefan