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: 
achakilam1022
Creator II
Creator II

Aggregation on Calculated Dimension

Hi all,

I've a calculated dimension 'FinalSegment' and I need to create a Cost measure which uses aggregation on FinalSegment. I tried the following and it didn't work.

I've created variable vFinalSegment :  if(len(trim(Segment))=0,Segment_2,Segment)


Cost =

     sum(aggr(Cost, ID,Buyer,$(vFinalSegment) ))


But, this measure  returns 0.


May I know how to do this?


Thanks!

6 Replies
devarasu07
Master II
Master II

hi,

try like this

Method 1:

create calculated dimension

aggr(sum( {$<Segment={"=len(trim(Segment))<=0"}>}cost),Segment_2,Segment)

method 2:

dimension:

Segment

Segment_2

Measure:

sum( {$<Segment={"=len(trim(Segment))<=0"}>}cost)

if still not working, try to share mock data with expected output in excel format

 

Thanks,

Deva

Anil_Babu_Samineni

Can you replace it to first place

Sum(aggr($(vFinalSegment),Cost, ID,Buyer))


Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
sunny_talwar

Are you evaluating your variable rowwise or chartwise? For chart wise, may be try one of the two:

Sum(Aggr(Cost, ID, Buyer, $(=vFinalSegment)))

Or

Sum(Aggr(Cost, ID, Buyer, $(=$(vFinalSegment))))

or if this is row wise, may be this

Sum(Aggr(Cost, ID, Buyer, Segment_2, Segment))

achakilam1022
Creator II
Creator II
Author

Hi Sunny,

I'm, doing it chart wise; I've tried the expressions you've suggested but  they are returning 0

Any clue what could be going wrong?

I appreciate your help. Thanks!

sunny_talwar

Would you be able to share a sample to check this out?

achakilam1022
Creator II
Creator II
Author

I've made some changes in script load editor

I appreciate your help