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

how to write a set expression for sales in current year and not in previous year?

Hi All ,

how to write a set expression for sales in current year and not in previous year?

Thanks

John

12 Replies
jonasheisterkam
Partner - Creator III
Partner - Creator III

Hie hope this helps.

=Sum({<Year={'$(=year(Today()))'}>}Sales)

Anonymous
Not applicable
Author

Hi,

Try:

=Sum({<Year={$(=Max(Year))}>} Sales )

or

=Sum({<Year={'$(=year(Today()))'}>}Sales)

or

=SUM({$<Date = {'>=$(=YearStart(Today()))<=$(=MonthEnd(Today()))'}>}Sales)

Regards

Neetha

Not applicable
Author

Thanks Neetha.

Can you please explain me, how this expression will check weather sales are present in previous year or not.

simonc-cfn
Contributor III
Contributor III

Hi John,

I believe the following set analysis expression may provide you with the results you seek.

sum({$<[Order Year] = p({$<[Order Year]={$(=max([Order Year]))}>}

[Order Year]) - p({$<[Order Year]={$(=max([Order Year])-1)}>}

[Order Year])>} Quantity)

Please note that the Max aggregation used is assuming that the max possible year is current year. Feel free to adjust as needed.

I hope this helps.

Simon

Anonymous
Not applicable
Author

Hi,

Mistake,to check sales not in previous year,use below syntax:

=Sum({<Year={$(=Max(Year))},Year -= {'$(=Year(Today())-1)'}>} >} Sales )

or

=Sum({<Year={'$(=year(Today()))'},Year -= {'$(=Year(Today())-1)'}>} >}Sales)

or

=SUM({$<Date = {'>=$(=YearStart(Today()))<=$(=MonthEnd(Today()))'},Year -= {'$(=Year(Today())-1)'}>} >}Sales)

Regards

Neetha

Not applicable
Author

Hi Simon Calzada

Can you Please Explain me How this P() function Works, if you provide any Detailed Doc on P()  it will be helpful for me .

Thanks

John

jonasheisterkam
Partner - Creator III
Partner - Creator III

P() selects all possible values of the field => white/green

E() selects all excluded values => grey

engishfaque
Specialist III
Specialist III

Dear John,

Here is an expression, please check.

Current Year Sales Expression:

=Sum ({$<Year = {$(=Only (Year))}>} Sales)

Kind regards

Ishfaque Ahmed

Not applicable
Author

Hi Jonas Heisterkamp,

Can you Please explain me with an example where it is useful, where can we use it.

Regards

John