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.

1 Solution

Accepted Solutions
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

View solution in original post

24 Replies
awhitfield
Partner - Champion
Partner - Champion

Hi uday,

can you upload a sample qvw and source data please?

Andy

Kushal_Chawda

You need to use the Aggr function which will aggregate the values based on dimension.

As you are using the cyclic group, you can use Aggr function with Getcurrentfield fucntion

Try,

=sum(aggr(sum([Sales to date]),$(=GetCurrentField(YourCyclicGroupName))))/

sum(aggr(sum([Billing Days to date]),$(=GetCurrentField(YourCyclicGroupName))))

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Try setting the Total mode of that expression to Sum of rows instead of Expression Total.


talk is cheap, supply exceeds demand
Anonymous
Not applicable
Author

I have set the total mode as sum of rows for Sales to date and Billing days to date, but for the final sales calculation I have set the total mode to Expression total, as I want even the total of "Final Sales Calculation" to be the divided value of the "Billing days to date total " and "Sales to date Total". If I set all of them to sum of rows, I get only the sum of Final sales calculation which is not the requirement. 

Anonymous
Not applicable
Author

Hi Kush,

The expression you gave did not work. Instead it is returning the nulls.

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Change your expression to: sum([Sales to date])/sum(Billing Days to Date])


talk is cheap, supply exceeds demand
Kushal_Chawda

UdayKiran‌ it should work. Have you correctly entered your cyclic group name?

or please share the screenshot of your expression

Not applicable
Author

In total mode Keep sum of rows for the expression: [Sales to date}/[Billing Days to Date]) and for other exprs keep Expressions Total and try..

Anonymous
Not applicable
Author

It has returned NULL.