Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
tomgury
Contributor II
Contributor II

Year On Year Comparison not working

Hello,

I would like to compare a Year on Year Comparison for New Clients (New Client's is by first order date).

My Main Date Is based on the Order Date of the client.

Sometimes The Client's last purchase is on the same year (First Order Date is in 2019 and last order date is also on 2019)

In those cases, When I choose the year 2020 for example, When I want to count the new clients for 2019, I miss those clients that stopped buying in 2019 because the date field is based on the Order Date which has stopped in 2019.

Here is my Measure expression for last Year comparison. can anyone help me on how to choose Year 2020 and still count those clients who stopped buying in 2019 and are scraped as soon as i choose year 2020?:

 

=Sum(IF([Client Go Live Date] <= AddYears('$(vTotalMaxDate)',-1) And [ClientGo Live Date] >= AddYears('$(vTotalMinDate)',-1) ,1 ,0))

 

vTotalMaxDate = Max(Date)

vTotalMinDate = Min(Date)

 

How Can I change vTotalMaxDate  And vTotalMinDate So that the Date will also take into account not just the Clients min and max order dates, but every date?

 

Thanks,

Tom

1 Reply
edwin
Master II
Master II

My understanding is you select a date (or Year) and you want to compare to prior year new customers.

1. you already have a golive date (i assume this is the first date the customer was added).  i suggest to make it easier, create a field GoLiveYear which is = year(GoLiveDate) in your data model

2. store the selected year in a variable vThisYear=only(Year) if the user selects year, or =year(Date) if date is selected; create vPriorYear=vThisYear-1
3. in your expression, prior year customer count is =count( distinct {<GoLiveYear={$(vPriroYear)}>}CUSTOMERID)