Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
naziralala
Creator
Creator

Sum on Unique Values in Chart

Hello All,

Here is a new problem as below:

I am trying to Sum the Stay only based on Distinct Booking Code in a chart expression.

The code is below:

sum(  [DISTINCT]<BookingCode> Stay)

But this is giving error in expression.

I also tried using the code as below:

aggr( Distinct sum(Stay), BookingCode )

or

Sum({<BStatus={'RES'}>[Distinct] BookingCode},Stay)

and also

Sum(Aggr(Count(DISTINCT BookingCode),Stay) )

The last one works, but I do not get the desired result.

Can anyone please assist.

Thanks in advance.

1 Solution

Accepted Solutions
sunny_talwar

May be this:


Sum(Aggr(Only({<bstatus = {'Res'}>} Stay), BookingCode))

View solution in original post

7 Replies
sunny_talwar

May be this:

Sum(Aggr(Sum(DISTINCT Stay), BookingCode))

or

Sum(Aggr(Avg(Stay), BookingCode))

or

Sum(Aggr(Only(Stay), BookingCode))

effinty2112
Master
Master

Hello,

               If there is only one distinct value of Stay for each BookingCode then try this expression:

Sum(AGGR(Only(Stay),BookingCode))

Cheers

Andrew

robert_mika
Master III
Master III

Maybe

Sum(Aggr(sum(DISTINCT BookingCode),Stay) )

naziralala
Creator
Creator
Author

The same Booking code appears multiple times, having same stay. Also, the

bstatus needs to be considered as Res. How can i incorporate that as well?

Please assist.

sunny_talwar

May be this:


Sum(Aggr(Only({<bstatus = {'Res'}>} Stay), BookingCode))

vikramv
Creator III
Creator III

like .....

Sum(Aggr(sum(DISTINCT {<bstatus={'Res'}>} BookingCode),Stay) )

naziralala
Creator
Creator
Author

Hello,


Can you please assist why the code below is not working correctly?

Sum(Aggr(Max({<bstatus = {'Res'},BookingYear={$(=Max(BookingYear)-1)}>} Cost), BookingCode))

The below works fine though:

Sum(Aggr(Max({<bstatus = {'Res'}>} Cost), BookingCode))


Thanks