Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Total Sales Calculation Problem

Hi Everyone,

     I have created a straight Table for sales calculation with respect to billing days. I have loaded the Billing and Sales values per year and country wise and I have used the division formula (i.e [Sales to date}/[Billing Days to Date]) to perform the calculation to show the final sales in the respective years. The problem now is, the formula works fine for individual sales vs billing days and gives the correct output. But when it comes to the totals the division operation is not performing well. Can anyone please tell me where I might be doing the mistake. I am attaching the screenshot for reference.

Thanks in advance.

24 Replies
Anonymous
Not applicable
Author

This is the sample app and data replicating the original app, whose file size is around 90 GB so I sent the sample data with almost the same fields. The last field CSales/[No. of Billing Days] is the prototype of the field I mentioned in my original post. " No. of Billing Days" resembles the " Billing Days to date" and "CSales" is "Sales to date" in my original app.

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

See attached qvw. Does that calculate what you want? If it doesn't please post the results that you do expect based on the sample data in the document you posted.


talk is cheap, supply exceeds demand
Anonymous
Not applicable
Author

I have checked your qvw. It is giving the same result I am already getting. For me the final calculation based on CSales/No. of Billing Days is correct for individual values based on year and country are correct. Whereas for totals the calculation is incorrect. For example:

Country     Year     No. of Bill Days     CSales     Division formula output     Status

Germany     2014     6                         81886.33     13647.72                       Correct

Germany     2015     6                         36384.05     6064.01                         Correct

UK             2014     7                         70037.19     10005.31                       Correct

UK             2015     7                           42138.26     6019.75                        Correct

Total                         26                        230445.84   8863.30(Expected)

                                                                               11686.42(Actual)

The problem I understood here is the while dividing the totals, it is dividing by taking  the "Expression totals of CSales and No. of Billing Days" instead of total of "Sum of Rows" and performing division operation on those values. Pardon me if it is still not clear.

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Ok, try this expression:

=sum(aggr(if(Year=year(Date1),

       sum({<Date={">=$(=vStartDate)<=$(=vEndDate)"},year=>}Sales),

       sum({<Date={">=$(=Vprestdate)<=$(=Vpreendate)"},year=>}Sales)

     ),Country,Year))

/

sum(aggr(sum({<Date1={">=$(vStartDate)<=$(vEndDate)"}>}[Billing Day]),Country,Year))


talk is cheap, supply exceeds demand
Anonymous
Not applicable
Author

Hi,

It is working fine in the sample application. Trying to implement the same in my original app. Thank you very much for the help.