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: 
johngouws
Partner - Specialist
Partner - Specialist

Cost comparison to LY

I have an existing Sales app and I would like to compare the cost prices of the items I sold this year to the same items sold the previous year.

Currently I have this expressions to calculate this ytd values:

SUM({<[Sales_Fin_Year]=,Sales_Month=,Date = {">=$(=YearStart(Today(),0))<=$(=AddYears(Today(),0))"} >} [Unit Cost])

and SUM({<[Sales_Fin_Year]=,Sales_Month=,Date = {">=$(=YearStart(Today(),-1))<=$(=AddYears(Today(),-1))"} >} [Unit Cost]) to calculate previous ytd.

I would like to only show the costs for item sold this years as well as last year and exclude items that were sold in only one of the two years.

I am not entirely sure if this can be done but would appreciate any help in this regard.

Thanking you.

1 Solution

Accepted Solutions
andrey_krylov
Specialist
Specialist

Hi, John, try to multiply by the condition of the fact of sales in a related year

your first expr

SUM({<[Sales_Fin_Year]=,Sales_Month=,Date = {">=$(=YearStart(Today(),0))<=$(=AddYears(Today(),0))"} >} [Unit Cost])  * If( Aggr(SUM({<[Sales_Fin_Year]=,Sales_Month=,Date = {">=$(=YearStart(Today(),-1))<=$(=AddYears(Today(),-1))"} >} [Unit Cost]) , [You Item Field]) > 0, 1)

second expr

SUM({<[Sales_Fin_Year]=,Sales_Month=,Date = {">=$(=YearStart(Today(),-1))<=$(=AddYears(Today(),-1))"} >} [Unit Cost]) * If( Aggr(SUM({<[Sales_Fin_Year]=,Sales_Month=,Date = {">=$(=YearStart(Today(),0))<=$(=AddYears(Today(),0))"} >} [Unit Cost]), [You Item Field]) > 0, 1)

View solution in original post

2 Replies
andrey_krylov
Specialist
Specialist

Hi, John, try to multiply by the condition of the fact of sales in a related year

your first expr

SUM({<[Sales_Fin_Year]=,Sales_Month=,Date = {">=$(=YearStart(Today(),0))<=$(=AddYears(Today(),0))"} >} [Unit Cost])  * If( Aggr(SUM({<[Sales_Fin_Year]=,Sales_Month=,Date = {">=$(=YearStart(Today(),-1))<=$(=AddYears(Today(),-1))"} >} [Unit Cost]) , [You Item Field]) > 0, 1)

second expr

SUM({<[Sales_Fin_Year]=,Sales_Month=,Date = {">=$(=YearStart(Today(),-1))<=$(=AddYears(Today(),-1))"} >} [Unit Cost]) * If( Aggr(SUM({<[Sales_Fin_Year]=,Sales_Month=,Date = {">=$(=YearStart(Today(),0))<=$(=AddYears(Today(),0))"} >} [Unit Cost]), [You Item Field]) > 0, 1)

johngouws
Partner - Specialist
Partner - Specialist
Author

Hi, Andrey. thank you very much for this solution. It is exactly what I was looking for.