Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
oscarvictory
Contributor III
Contributor III

Aggr percentage from different type of data

Hi all, hope some of you can help me.

As you can see the % is right for each row but not for the TOTAL. I guess that's because I'm mixing different items to the aggr (ITEM_LINE vs. INVOICE). Any suggestion?

This is a sample of my table and my code:

oscarvictory_1-1654011041720.png

IF(Match(ITEM, 'A'),

(Sum(Aggr(SUM({$<ItemYear={$(=vCurrentYear)}, ITEM = {"A"}>} BASE_FAC)
/ Sum({$<ItemYear={$(=vCurrentYear)}, ITEM = {"A"}>} HOURS), ITEM_LINE)) -

Sum(Aggr(SUM({$<ItemYear={'$(=vCurrentYear-1)'}, ITEM = {"A"}>} BASE_FAC)
/ Sum({$<ItemYear={'$(=vCurrentYear-1)'}, ITEM = {"A"}>} HOURS), ITEM_LINE))) /

Sum(Aggr(SUM({$<ItemYear={'$(=vCurrentYear-1)'}, ITEM = {"A"}>} BASE_FAC)
/ Sum({$<ItemYear={'$(=vCurrentYear-1)'}, ITEM = {"A"}>} HOURS), ITEM_LINE)),

(Sum(Aggr(SUM({$<ItemYear={$(=vCurrentYear)}, ITEM -= {"A"}>} BASE_FAC)
/ Count({$<ItemYear={$(=vCurrentYear)}, ITEM -= {"A"}>} distinct INVOICE), ITEM_LINE)) -

Sum(Aggr(SUM({$<ItemYear={'$(=vCurrentYear-1)'}, ITEM -= {"A"}>} BASE_FAC)
/ Count({$<ItemYear={'$(=vCurrentYear-1)'}, ITEM -= {"A"}>} distinct INVOICE), ITEM_LINE))) /

Sum(Aggr(SUM({$<ItemYear={'$(=vCurrentYear-1)'}, ITEM -= {"A"}>} BASE_FAC)
/ Count({$<ItemYear={'$(=vCurrentYear-1)'}, ITEM -= {"A"}>} distinct INVOICE), ITEM_LINE)))

 

Many TKS!

Labels (1)
1 Solution

Accepted Solutions
oscarvictory
Contributor III
Contributor III
Author

Many TKS Vineeth, 

That does not work for me because I'm working with straight table not pivot.

Anyway I did find out an easer way:

(Column(2) - Column(4)) / Column(4)

Rgds.

 

 

 

 

View solution in original post

2 Replies
vinieme12
Champion III
Champion III

=if(Dimensionality() = 0

,

Expression to show in TOTAL row goes here

,

IF(Match(ITEM, 'A'),

(Sum(Aggr(SUM({$<ItemYear={$(=vCurrentYear)}, ITEM = {"A"}>} BASE_FAC)
/ Sum({$<ItemYear={$(=vCurrentYear)}, ITEM = {"A"}>} HOURS), ITEM_LINE)) -

Sum(Aggr(SUM({$<ItemYear={'$(=vCurrentYear-1)'}, ITEM = {"A"}>} BASE_FAC)
/ Sum({$<ItemYear={'$(=vCurrentYear-1)'}, ITEM = {"A"}>} HOURS), ITEM_LINE))) /

Sum(Aggr(SUM({$<ItemYear={'$(=vCurrentYear-1)'}, ITEM = {"A"}>} BASE_FAC)
/ Sum({$<ItemYear={'$(=vCurrentYear-1)'}, ITEM = {"A"}>} HOURS), ITEM_LINE)),

(Sum(Aggr(SUM({$<ItemYear={$(=vCurrentYear)}, ITEM -= {"A"}>} BASE_FAC)
/ Count({$<ItemYear={$(=vCurrentYear)}, ITEM -= {"A"}>} distinct INVOICE), ITEM_LINE)) -

Sum(Aggr(SUM({$<ItemYear={'$(=vCurrentYear-1)'}, ITEM -= {"A"}>} BASE_FAC)
/ Count({$<ItemYear={'$(=vCurrentYear-1)'}, ITEM -= {"A"}>} distinct INVOICE), ITEM_LINE))) /

Sum(Aggr(SUM({$<ItemYear={'$(=vCurrentYear-1)'}, ITEM -= {"A"}>} BASE_FAC)
/ Count({$<ItemYear={'$(=vCurrentYear-1)'}, ITEM -= {"A"}>} distinct INVOICE), ITEM_LINE)))  )

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
oscarvictory
Contributor III
Contributor III
Author

Many TKS Vineeth, 

That does not work for me because I'm working with straight table not pivot.

Anyway I did find out an easer way:

(Column(2) - Column(4)) / Column(4)

Rgds.