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: 
oscarvictory
Contributor III
Contributor III

Sum Aggr expression Issue

Hi all, hope you can help me with this little issue.

Here is a table where COST column is the result of FACT_DPT/FACT_TOT * TOT_COST:

(SUM({1<ANYOlinfact={$(=vActualYear)}, PROFIT ={"Eat"}, TYPE ={"COST"}, Cost = {">0"}>} factlin* Price))

/

(SUM({1<ANYOlinfact={$(=vActualYear)}, TYPE ={"COST"}, PROFIT -={"Dora"}, Cost = {">0"}>} factlin* Price) - (Sum({1<TYPE ={ 'COM'}, CodCli = {2447}>} Cost)))


* Max({<TYPE ={"COST"} >} Cost)

oscarvictory_3-1603471072227.png

 

Problem arise when I insert above formula into Pivot Table containing Customer & Month.

oscarvictory_2-1603470643412.png

((Sum(aggr(SUM(total{1<ANYOlinfact={$(=vActualYear)}, PROFIT ={"Eat"}, TYPE ={"COST"}, Cost = {">0"}>} total <MONTH > factlin* Price), MONTH, CUSTOMER )))

/

Sum(aggr(SUM(total{1<ANYOlinfact={$(=vActualYear)}, TYPE ={"COST"}, PROFIT -={"Dora"}, Cost = {">0"}>} total <MONTH > factlin* Price)- Sum(total{1<TYPE ={ 'COM'}>} Cost),MONTH, CUSTOMER))

* aggr(sum(total{1<TYPE ={"COST"} >} Cost), MONTH, CUSTOMER ))

 

Many TKS in advance.

 

 

1 Solution

Accepted Solutions
marcus_sommer

Try it in this way:

Sum(aggr(
(SUM({1<ANYOlinfact={$(=vActualYear)}, PROFIT ={"Eat"}, TYPE ={"COST"}, Cost = {">0"}>} factlin* Price))

/

(SUM({1<ANYOlinfact={$(=vActualYear)}, TYPE ={"COST"}, PROFIT -={"Dora"}, Cost = {">0"}>} factlin* Price) - (Sum({1<TYPE ={ 'COM'}, CodCli = {2447}>} Cost))) * Max({<TYPE ={"COST"} >} Cost),
MONTH, CUSTOMER ))

- Marcus

View solution in original post

2 Replies
marcus_sommer

Try it in this way:

Sum(aggr(
(SUM({1<ANYOlinfact={$(=vActualYear)}, PROFIT ={"Eat"}, TYPE ={"COST"}, Cost = {">0"}>} factlin* Price))

/

(SUM({1<ANYOlinfact={$(=vActualYear)}, TYPE ={"COST"}, PROFIT -={"Dora"}, Cost = {">0"}>} factlin* Price) - (Sum({1<TYPE ={ 'COM'}, CodCli = {2447}>} Cost))) * Max({<TYPE ={"COST"} >} Cost),
MONTH, CUSTOMER ))

- Marcus

oscarvictory
Contributor III
Contributor III
Author

Perfect Marcus!!. Many Thanks!!.