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: 
guillaume_gorli
Creator II
Creator II

Year to Date figure

Dear All,

I am trying to build a Yeart to date figure based on the user selection.

Let me explain :

I am using below test table with two colums : Date and Sales

 

DateSales
01/01/201515
03/01/201520
16/02/20151
17/02/20157
19/02/201512
01/03/201520
01/04/201528
25/05/201585
01/01/201610
10/01/201615
01/02/201620
10/02/201610
25/02/201635
01/03/201615
01/04/201617
01/05/201635
01/05/201640

Based on the period selection i need to sum this up in a table showing sales by month, sales by month of the previous year, year to date sales and year to date sales of the previous year.

No issue to get the sales per month as well as the sales for the period of the previous year...

Capture.JPG

But i can't manage to get the year to date results.

If year 2016 is selected, final output should be like below table :

Capture.JPG

Atteched is .qvw as well as excel database for the ones who want to help.

Thanks in advance

Guillaume

1 Solution

Accepted Solutions
sunny_talwar

Change Sale Y-1 formula to this:

=If(Sum (Sales)> 0,Sum({$<[Année]={$(=only(Année)-1)},Mois= {JAN,FEB,MAR,APR,MAY,JUN,JUL,AUG,SEP,OCT,NOV,DEC}>}(Sales)))


Capture.PNG

View solution in original post

7 Replies
sunny_talwar

Try these expressions:

If(Sum (Sales) > 0, RangeSum(Above(Sum(Sales), 0, RowNo())))

=If(Sum (Sales) > 0, RangeSum(Above(Sum({$<[Année]={$(=only(Année)-1)},Mois= {JAN,FEB,MAR,APR,MAY,JUN,JUL,AUG,SEP,OCT,NOV,DEC}>}Sales), 0, RowNo())))


Capture.PNG

guillaume_gorli
Creator II
Creator II
Author

Thanks Sunny for the quick feedback.

The table results are correct although when i do select a month, it's not working :

Where it should looks like :

Capture.JPG

output table is shown as below :

Capture.JPG

Guillaume

sunny_talwar

Change Sale Y-1 formula to this:

=If(Sum (Sales)> 0,Sum({$<[Année]={$(=only(Année)-1)},Mois= {JAN,FEB,MAR,APR,MAY,JUN,JUL,AUG,SEP,OCT,NOV,DEC}>}(Sales)))


Capture.PNG

guillaume_gorli
Creator II
Creator II
Author

Thanks Sunny, it's perfect !

sunny_talwar

Here is another method:

LOAD Date,

    Sales

FROM

[TEST YTD.xlsx]

(ooxml, embedded labels, table is Feuil1);

Join (Feuil1)

LOAD Date(AddYears(Date, 1)) as Date,

  Sales as Previous_Sales

Resident Feuil1;



Expression1:

1) Sum (Sales)

2) Sum (Previous_Sales)

3) If(Sum (Sales) > 0, RangeSum(Above(Sum(Sales), 0, RowNo())))

4) If(Sum (Sales) > 0, RangeSum(Above(Sum({<Mois>}Previous_Sales), 0, RowNo())))

Output will still stay the same.



guillaume_gorli
Creator II
Creator II
Author

Dear sunny, i am creating a new topic as i am still struggling with this app...I will define more precisely what are the final output needed.

sunny_talwar

Sounds good