Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
renjithpl
Specialist
Specialist

Aggr Issue

Hi All,

I have a table like below

 

RegionIDBUUBenefitFlagSales
AmericaAISS0100
AmericaABCS1200
AmericaAHPN0500
AmericaBISS1300
AmericaBTS1500
AmericaBStorage0600

My Output table (Pivot) has two expressions.

1. =sum(aggr(sum({<BenefitFlag = {1}>}Sales), BUU, ID))      - Sales with benefits

2. =sum(aggr(sum({<BenefitFlag -= {1}>}Sales), BUU, ID))     -  Sales without benefits

Output table when no selection made

Regionwith_Benefitwithout_Benefit
America10001200

When I select BUU only (any one BUU)

eg. ISS is selected

Regionwith_Benefitwithout_Benefit
America300200

When I select More than one BUU for eg. I selected ISS and BCS

My output comes like below

Regionwith_Benefitwithout_Benefit
America500100

But my requirement is to get 600 in with_benefit and 0 in without benefit.

Regionwith_Benefitwithout_Benefit
America6000

Actually when you select ISS and BCS, look at the total of the BenefitFlag = 1 (0+1) for the ID A so that 100 also should come in with_Benefit bucket.

Any idea. ?

Thanks

Renji

1 Solution

Accepted Solutions
sunny_talwar

Try these

with

If(GetSelectedCount(BUU) = 0, Sum({<BenefitFlag = {1}>}Sales), Sum({<ID = {"=Sum(BenefitFlag) > 0"}>} Sales))

without

If(GetSelectedCount(BUU) = 0, Sum({<BenefitFlag -= {1}>}Sales), Sum({<ID = {"=Sum(BenefitFlag) = 0"}>} Sales))

View solution in original post

5 Replies
Vegar
MVP
MVP

Aggr Issue.PNG

Try to use indirect set analysis using P() and E()

Sales with benefits

=sum(aggr(sum({<Region = p({<BenefitFlag = {1}>})>}Sales), BUU, ID))


Sales without benefits

=sum(aggr(sum({<Region = E({<BenefitFlag = {1}>})>}Sales), BUU, ID))

sunny_talwar

Would you be able to share some other expected results for other selection? I am guessing that ISS and BCS are not unique which require a particular kind of results. It would be helpful to understand the logic behind your expected result for different selections

renjithpl
Specialist
Specialist
Author

Here i am selecting ISS, HPN and Storage,

Inputtable after selection

   

RegionIDBUUBenefitFlagSales
AmericaAISS0100
AmericaAHPN0500
AmericaBISS1300
AmericaBStorage0600

So from the above table if you look at ID B, the sum of BenefitFlag is greater than 0 (1+0) and sum of BenefitFlag for ID A is equal to 0 (0 + 0).

if its greater than 0, then sum the sales (600 +300) and will be in the Sales_with_Benefit bucket, else, 500 +100 will be in the without bucket.

So my output should be like below

 

Regionwithwithout
America900600

thanks for your help..

sunny_talwar

Try these

with

If(GetSelectedCount(BUU) = 0, Sum({<BenefitFlag = {1}>}Sales), Sum({<ID = {"=Sum(BenefitFlag) > 0"}>} Sales))

without

If(GetSelectedCount(BUU) = 0, Sum({<BenefitFlag -= {1}>}Sales), Sum({<ID = {"=Sum(BenefitFlag) = 0"}>} Sales))

renjithpl
Specialist
Specialist
Author

Bingo..!!