Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Posting on Qlik Community is temporarily paused for some users. Thank you for patience and we'll update you soon!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

previous month

i have a problem with the previous month

vPrevMonth2 =  =Month(AddMonths(Date(Today()),-1))

sum({$<Month={'$(vPrevMonth2)'},Year=,Month=,Day=>}IF((SALESPRICE)*QTYORDERED=0,' ',SALESPRICE*QTYORDERED))

sum(IF((SALESPRICE)*QTYORDERED=0,' ',SALESPRICE)*QTYORDERED)

Why are the results in my pivot in both coluns the same?

Labels (1)
6 Replies
jonathandienst
Partner - Champion III
Partner - Champion III

Hi

That's because the set expression is broken in some way.

You might just need an = sign here:          $(=vPrevMonth2)

Did you test  that this works correctly?

{$<Month={'$(=Month(AddMonths(Today()-1)))'}, Year=, Month=, Day=>}

Is the field Month in the same format and language as that returned by the Month function?

HTH

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Not applicable
Author

i need = sign but nothing happens.

when i select a special month for exampel Sep in the second column the result is right and in the first column nothing changes, it shows the whole numbers...

Not applicable
Author

...and when i test my variable in a text box i get the right result...

stigchel
Partner - Master
Partner - Master

The problem is that in your set expression you first define Month to be a specific month, and later disregard that selction again by saying Month=,. Remove the Month=, so:

sum({$<Month={'$(vPrevMonth2)'},Year=,Day=>}IF((SALESPRICE)*QTYORDERED=0,' ',SALESPRICE*QTYORDERED))

Not applicable
Author

with this formula it works

sum({<Year={'$(vPrevMonthYear)'},Month={'$(vPrevMonth)'},TCMSALESORDERDATE=,MonthYear=>}IF((NAME_ECORESATTRIBUTE)

='Produktserie',SALESPRICE*QTYORDERED))

stigchel
Partner - Master
Partner - Master

In this expression you have no duplicate field selections (Year=Value, disregard sel MonthYear).

I tested the Month=Sel, Month= in set expression and the combination will disregard the Month=Sel with Month=. Have you tried my suggestion?