Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
matancha
Creator
Creator

Set Analysis with variables

Hello all.

I'm want to show sales in the same period (of selection) of 12 months back

.

I hold 2 variables:

vDateMin = MonthStart(AddMonths(min(Date), -12))

vDateMax = MonthEnd(AddMonths(Max(Date), -12))

And now I want to use the variable in pivot table expression like: Sum({$<Date = {"> $(#vDateMin) < $(#vDateMax)"}>}$(vSales))

and It doesn't work for me.

if I do it manually like this: Sum({$<Date = {">=01/01/2011 <= 28/02/2012"}>}$(vSales))  Its work fine.

What am I doing wrong?

Tnks -

Matan.

1 Solution

Accepted Solutions
jagan
Luminary Alumni
Luminary Alumni

Hi,

Try this expression

vDateMin = MonthStart(AddMonths(Max(Date), -12))

vDateMax = MonthEnd(AddMonths(Max(Date), -12))

=Sum({<YearDimensionName=, MonthDimensionName=, QuarterDimensionName=, Date = {">=$(=vDateMin)<=$(=vDateMax)"}>}$(vSales))

Exclude the date filters like Year, Month or Quarter selections if there are any.  Also check whether the date formats are same in Variable and Dimension.

Hope this helps you.

Regards,

Jagan.

View solution in original post

6 Replies
fdelacal
Specialist
Specialist

Hi plzmatanch

Sum({$<Date = {"$(='>'&(vDateMin)&'<'(vDateMax)"}>}$(vSales))

please trie this way.

hope that helps you.

jagan
Luminary Alumni
Luminary Alumni

Hi,

Try this expression

vDateMin = MonthStart(AddMonths(Max(Date), -12))

vDateMax = MonthEnd(AddMonths(Max(Date), -12))

=Sum({<YearDimensionName=, MonthDimensionName=, QuarterDimensionName=, Date = {">=$(=vDateMin)<=$(=vDateMax)"}>}$(vSales))

Exclude the date filters like Year, Month or Quarter selections if there are any.  Also check whether the date formats are same in Variable and Dimension.

Hope this helps you.

Regards,

Jagan.

its_anandrjs

Hi,

Please check your date format of the variable  Date  .

Regards,

Anand

Not applicable

your script working fine.

try this

=Sum({$<Date = {'> $(=vDateMin) <$(=vDateMax)'}>}$(vSales))

matancha
Creator
Creator
Author

Tnks jagan.

I Think that my problem was that I didn't do the "Year=...."

many thanks to all of you for your answers -

Matan.

vinod22kv
Creator
Creator

Hi,

can i have some simple example on this please.

Regards,

Vinod